604 Android Programming | 2 Marks Questions with Answer

AP

Answer the following questions 


1.       What are the features of Android?

Ans :

1. Application Framework: It enables reuse and replacements of components.

2. Dalvik Virtual Machine: It is optimized for mobile device.

3. Integrated Browser: It is based on open source web kit engine.

4. Handset layouts: Optimized Graphics: It is powered by a custom 2D graphics Library 3D Graphics based on the OpenGL ES 1.0 Specification.

5. Storage: SQLite, a lightweight relational database.

6. Media Support: Android supports the following audio/video/still media formats: H.263, H.264 (in 3GP or MP4 container), MPEG 4 SP, AMR, AMR WB (in 3GP container), AAC, HE AAC (in MP4 or 3GP container), MP3, MIDI, Ogg Vorbis,  WAV, JPEG, PNG, GIF, BMP

7. Connectivity: GSM/EDGE, IDEN, CDMA, EVDO, UMTS, Bluetooth, WiFi.

8. Messaging: SMS and MMS are available forms of messaging, also support  Android Cloud to Device Messaging Framework (C2DM).

9. Multiple Language Support: Multiple Languages Available in Android.

10. Additional hardware support: Android can use video/still cameras, touch screens, GPS, accelerometers, gyroscopes, magnetometers.









2.       Explain the Android stack diagrammatically/ Android architecture.

 Ans :

Linux kernel: This is the kernel on which Android is based. This layer contains all the low level device drivers for the various hardware components of an Android device.

Libraries: These contain all the code that provides the main features of an Android OS. For example, the SQLite library provides database support so that an application can use it for data storage. The Webkit library provides functionalities for web browsing.

Android runtime: At the same layer as the libraries, the Android provides a set of core libraries that enable developers to write Android apps using the Java programming language.

Application framework: Exposes the various capabilities of the Android OS to application developers so that they can make use of them in their applications.





3.       Explain SDK platform in deatil. 

Ans :

The Android SDK (Software Development Kit) is the most important software of android which is installed. The Android SDK provides to test android applications, the API libraries, an emulator, documentation, sample code, developer tools and tutorials which help you to build, test and debug apps of Android SDK contains Debugger  Libraries Emulator Documentation Sample Code Tutorials Android SDK is made up of two main parts: the tools and the packages. When you first install the SDK, all you obtain are the base tools. Is helps you to develop applications. The packages are the records specific to a particular version of Android.





4.       What is activity?

Ans :

An activity is a window that contains the user interface of your applications. An application can have zero or more activities. Typically, applications have one or more activities, and the main aim of an activity is to interact with the user. From the moment an activity appears on the screen to the moment it is hidden, it goes through a number of stages, known as an activity's life cycle. Understanding the life cycle of an activity is vital to ensuring that your application works correctly.



5.       What is intent?

Ans :

The Android operating system uses an asynchronous messaging mechanism to match task requests with the appropriate Activity. Each request is packaged as an Intent The intent generally consists of activities to be done, the parameter over which this activity is to be performed, and the application to perform this action. Examples of processes defined as intents:

1. Start of certain activities.

2. Displaying a web page.

3. Answering a call.

4. Dialing a number.



6.       With the help of diagram describe activity life cycle.

Ans :



Method        Description

onCreate      called when activity is first created.

onStart        called when activity is becoming visible to the user.

onResume   called when activity will start interacting with the user.

onPause       called when activity is not visible to the user.

onStop         called when activity is no longer visible to the user.

onRestart     called after your activity is stopped, prior to start.

onDestroy    called before the activity is destroyed.



 





7.       Describe lifecycle of fragment diagrammatically.

Ans :

In Android, the fragment is the part of Activity which represents a portion of User Interface(UI) on the screen. It is the modular section of the android activity that is very helpful in creating UI designs that are flexible in nature and auto-adjustable based on the device screen size. The UI flexibility on all devices improves the user experience and adaptability of the application. Fragments can exist only inside an activity as its lifecycle is dependent on the lifecycle of host activity. For example, if the host activity is paused, then all the methods and operations of the fragment related to that activity will stop functioning, thus fragment is also termed as sub-activity.

 



8.       Enlist type of intents.

Ans :

Explicit Intent − It going to connect the internal world of an application such as start activity or send data between two activities.

Implicit Intents − It going to connect with out side application such as call, mail, phone,see any website ..etc.

9.       How to calling built-in applications using intents? Explain using example

Ans :

Calling built in applications using intents in Android is important as it give user more choices. For example in an app you want user make a call or open a document (pdf) let you use the in-build apps, take off the burden in developing those apps.

Android intent example

Lets get started with how to use intent in android. The following Try It Out demonstrates how to call some of the built-in applications commonly found on an Android device.

Creating New Project

1. First step : Open Android Studio and Create a new project by selecting 'Start a new Android Studio Project'. Give it a name MyIntent and a package name in.ruks. You can have your own application package names. Click next, choose minimum SDK, in ours case it is API 14. Android Studio will create the the new Android Project with all the necessary files.

Set up Project Layout

We are going to use 6 built-in application in this example. They are -

1. Gallery 2. Call Log 3. Contact 4. Dailler 5. Browser 6. Map

2. Second step : Now the time to set up the layout of our project. We are going to call 6 built-in applications using intents, hence we will place a button for each in activity_main.xml. You can drag and drop 6 button on the layout or simply create by coding the activity_main.xml file.

3. Third step : It's bad idea to have the hard coded string in the project. So in this android intent example code, we are given name to each of the button within the strings.xml, which is under the values folder in Android Studio. Add the code below in it -

Creating event handler

4. Fourth step : In our MainActivity.java file, we are going to declare the button for each of the Button we have created in our layout file.

5. Fifth step : Our Buttons are ready to have some action, now its time to attach the event handler to them. One by one we are going to call setOnClickListener method on each of our Button and call built-in applications.

Declare Activity in AndroidManifest

6. Final step : If you have basic knowledge of developing android apps then you must know that, every activity you have in your application must be declared in your AndroidManifest.xml file.



10.     What is UI?

Ans :

The user interface (UI) for an Android app is built as a hierarchy of layouts and widgets. The layouts are ViewGroup objects, containers that control how their child views are positioned on the screen. Widgets are View objects, UI components such as buttons and text boxes.





11.     What is layout? Enlist Layout Managers.

Ans :

A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with. Whereas a ViewGroup is an invisible container that defines the layout structure for View and other ViewGroup objects

layout Manager

1. A LinearLayout lines up its views in one row or column.

2. A FrameLayout is a simple layout manager used to display one view.

3. A RelativeLayout is a layout manager in which the views are positioned in relation to each other or to the parent.







12.     What is view?

Ans :

View is a basic building block of UI (User Interface) in android. A view is a small rectangular box that responds to user inputs. Eg: EditText, Button, CheckBox, etc. ViewGroup is an invisible container of other views (child views) and other ViewGroup.





13.     What is Action bar?

Ans :

The app bar, also known as the action bar, is one of the most important design elements in your app's activities, because it provides a visual structure and interactive elements that are familiar to users.





14.     Describe the following LayoutManagers with example:

Ans :

a.       LinearLayout

Linear layout is a simple layout used in android for layout designing. In the Linear layout all the elements are displayed in linear fashion means all the childs/elements of a linear layout are displayed according to its orientation. The value for orientation property can be either horizontal or vertical.

There are two types of linear layout orientation:

1. Vertical

2. Horizontal

b.       Tablelayout

A layout that arranges its children into rows and columns. A TableLayout consists of a number of TableRow objects, each defining a row (actually, you can have other children, which will be explained below). TableLayout containers do not display border lines for their rows, columns, or cells. Each row has zero or more cells; each cell can hold one View object. The table has as many columns as the row with the most cells. A table can leave cells empty. Cells can span columns, as they can in HTML.







15.     Explain the term utilizing action bar in detail.

Ans :

Action Bar is one of the important parts of any application, whether it’s a web application or a mobile app. Today we will learn how to implement an action bar in android apps using the ActionBar component.

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.

In general an ActionBar consists of the following four components:

App Icon: App branding logo or icon will be displayed here

View Control: A dedicated space to display Application title. Also provides option to switch between views by adding spinner or tabbed navigation

Action Buttons: Some important actions of the app can be added here

Action Overflow: All unimportant action will be shown as a menu







16.     What is ScrollView? Explain with example.

Ans :

a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it. A ScrollView supports Vertical scrolling only, so in order to create a horizontally scrollable view, HorizontalScrollView is used.



17.     With the help of diagram describe FrameLayout

Ans :

Frame Layout is one of the simplest layout to organize view controls. They are designed to block an area on the screen. Frame Layout should be used to hold child view, because it can be difficult to display single views at a specific area on the screen without overlapping each other.

We can add multiple children to a FrameLayout and control their position by assigning gravity to each child, using the android:layout_gravity attribute.

 



18.     What is the TextView?

Ans :

A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing.





19.     With the help of example explain RadioButton.

Ans :

RadioButton is a two states button which is either checked or unchecked. If a single radio button is unchecked, we can click it to make checked radio button. Once a radio button is checked, it cannot be marked as unchecked by user.

RadioButton is generally used with RadioGroup. RadioGroup contains several radio buttons, marking one radio button as checked makes all other radio buttons as unchecked.



20.     What is meant by button? Describe with example.

Ans :

In Android applications, a Button is a user interface that is used to perform some action when clicked or tapped. It is a very common widget in Android and developers often use it.





21.     What is the EditText?

Ans :

A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.





22.     Explain the AutoCompleteTextView in detail.

Ans :

A  AutoCompleteTextView is a view that is similar to EditText, except that it shows a list of completion suggestions automatically while the user is typing.

The AutoCompleteTextView is a type of edit text in android which gives suggestions to the user if the user types something in the AutoCompleteTextView. This type of edit text we can see while we register on some websites. If we type “In” it will suggest India, Indonesia, West Indies ….. etc. Like this, the AutoCompleteTextView works. Let us see the implementation of AutoCompleteTextView in XML and Java . Here XML is used to create the layout and java code is used to implement the main function of AutoCompleteTextView .





23.     Write short note on: ProgressBar.

Ans :

A progress bar is a graphical control element used to visualize the progression of an extended computer operation, such as a download, file transfer, or installation. Sometimes, the graphic is accompanied by a textual representation of the progress in a percent format.





24.     What is ToggleButton? How to create it? Explain with example.

Ans :

Android Toggle Button can be used to display checked/unchecked (On/Off) state on the button.

It is beneficial if user have to change the setting between two states. It can be used to On/Off Sound, Wifi, Bluetooth etc.

Since Android 4.0, there is another type of toggle button called switch that provides slider control.

Android ToggleButton and Switch both are the subclasses of CompoundButton class.

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 

xmlns:android="http://schemas.android.com/apk/res/android"  

    xmlns:app="http://schemas.android.com/apk/res-auto"  

    xmlns:tools="http://schemas.android.com/tools"  

    android:layout_width="match_parent"  

    android:layout_height="match_parent"  

    tools:context="example.javatpoint.com.togglebutton.MainActivity">  

      <ToggleButton  

        android:id="@+id/toggleButton"  

        android:layout_width="wrap_content"  

        android:layout_height="wrap_content"  

        android:layout_marginLeft="8dp"  

        android:layout_marginTop="80dp"  

        android:text="ToggleButton"  

        android:textOff="Off"  

        android:textOn="On"  

        app:layout_constraintEnd_toStartOf="@+id/toggleButton2"  

        app:layout_constraintStart_toStartOf="parent"  

        app:layout_constraintTop_toTopOf="parent" />  

  </android.support.constraint.ConstraintLayout>  









25.     Describe the following terms:

Ans :

a.       DatePicker : Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface. For this functionality android provides DatePicker and DatePickerDialog components.

b.       TimePicker : Android Time Picker allows you to select the time of day in either 24 hour or AM/PM mode. The time consists of hours, minutes and clock format. Android provides this functionality through TimePicker class.





26.     What is the gallery in Android?

Ans :

Gallery is an offline photo gallery. You can use it to edit, find, and manage photos without being connected to the Internet. Gallery also works with SD cards on Android devices. Tip: Gallery is available on Android devices.





27.     What is GridView in Android?

Ans :

A GridView is a type of AdapterView that displays items in a two-dimensional scrolling grid. Items are inserted into this grid layout from a database or from an array. The adapter is used for displaying this data, setAdapter() method is used to join the adapter with GridView. The main function of the adapter in GridView is to fetch data from a database or array and insert each piece of data in an appropriate item that will be displayed in GridView.





28.     What is ImageView in Android?

Ans :

ImageView class is used to display any kind of image resource in the android application either it can be android.graphics.Bitmap or android.graphics.drawable.Drawable (it is a general abstraction for anything that can be drawn in Android). ImageView class or android.widget.ImageView inherits the android.view.View class which is the subclass of Kotlin.Any class. Application of ImageView is also in applying tints to an image in order to reuse a drawable resource and create overlays on background images.





29.     Write short note on: Creating the helper methods.

Ans :

1. Provides common methods which are required by multiple classes in the project. 

2. Helper methods are generally public and static so that these can be invoked independently. 

3. Each methods of a helper class should work independent of other methods of same class.







30.     What is menu? Enlist its types.

Ans :

The traditional menu definition is a list of food or drink items available for purchase, or a list of food or drink items that will be served. That can be a seasonal menu, a fixed menu, or something in between. While the majority of the time the meaning of menu is applied to food and beverages, that’s not always the case.

The word menu is also used frequently in the context of electronic devices and computer programs. There it usually refers to a navigable list of options a user can interact with.

The five types of menus most commonly used are 1. a la carte menus, 2. static menus, 3. du jour menus, 3. cycle menus, and 3. fixed menus.





31.     What is thread?

Ans :

A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority.





32.     Enlist Types of handlers.

Ans :

Runnable, long) , postDelayed(Runnable, Object, long) , sendEmptyMessage(int) , sendMessage(Message) , sendMessageAtTime(Message, long) , and sendMessageDelayed(Message, long)





33.     What is SMS?

Ans :

We’re all familiar with SMS, or standard text messages. After all, it’s one of the oldest and most commonly used methods of mobile communication. While SMS is seemingly humdrum in the modern age, there’s a surprising amount of coordination and technology working in the background to send such seemingly simple messages. So let’s take a look at how it all works.



 

35.     What is Broadcast Receiver?

Ans :

A broadcast receiver (receiver) is an Android component which allows you to register for system or application events. All registered receivers for an event are notified by the Android runtime once this event happens.





36.     What is meant by database?

SQLite Database is an open-source database provided in Android which is used to store data inside the user's device in the form of a Text file. We can perform so many operations on this data such as adding new data, updating, reading, and deleting this data.





37.     What is SQLite?

SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is built into all mobile phones and most computers and comes bundled inside countless other applications that people use every day.



38.     Enlist feature of SQLite.

1. Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures.

2. Zero-configuration - no setup or administration needed.

3. Full-featured SQL implementation with advanced capabilities like partial indexes, indexes on expressions, JSON, common table expressions, and window functions. (Omitted features)

4. A complete database is stored in a single cross-platform disk file. Great for use as an application file format.

5. Supports terabyte-sized databases and gigabyte-sized strings and blobs. (See limits.html.)

6. Small code footprint: less than 750KiB fully configured or much less with optional features omitted.

7. Simple, easy to use API.

8. Fast: In some cases, SQLite is faster than direct filesystem I/O

9. Written in ANSI-C. TCL bindings included. Bindings for dozens of other languages available separately.

10. Well-commented source code with 100% branch test coverage.

11. Available as a single ANSI-C source-code file that is easy to compile and hence is easy to add into a larger project.

12. Self-contained: no external dependencies.







39.     How to close database using SQLite?

close( conn ) closes the SQLite connection by using the MATLAB® interface to SQLite. The SQLite connection object remains open until you close it using the close function. Always close this object when you finish using it.







40.     What is meant by Google map?

Google Maps is a Web-based service that provides detailed information about geographical regions and sites around the world. In addition to conventional road maps, Google Maps offers aerial and satellite views of many places. In some cities, Google Maps offers street views comprising photographs taken from vehicles.





41.     How to create Google map?

1. On your computer, sign in to My Maps.

2. Click Create a new map.

3. Go to the top left and click "Untitled map."

4. Give your map a name and description.



42.     What is marker? How to add markers in Google map.

Markers are objects of type Marker , and are added to the map with the GoogleMap. addMarker(markerOptions) method. Markers are designed to be interactive. They receive click events by default, and are often used with event listeners to bring up info windows.

How to Add :

1. On your computer, sign in to My Maps.

2. Open or create a map. A map can have up to 10,000 lines, shapes, or places.

3. Click Add marker .

4. Select a layer and click where to put the place. A layer can have 2,000 lines, shapes, or places.

5. Give your place a name.

6. Click Save

 

Post a Comment

0 Comments