Google News
logo
Android Interview Questions
The fragment in Android is as follows :
 
* A fragment has its own layout and behavior with its own life cycle callbacks.
* Fragments can be added or removed in an activity while the activity is running and used in multiple activities.
* Multiple fragments can be combined in a single activity to build a multi-pane UI.
* The fragment life cycle is closely related to the life cycle of its host activity which means when the activity is paused, all the fragments available in the activity will also be stopped
* Fragments were added to the Android API in the Honeycomb version of Android API version 11.
Some storage options available in Android are listed below :
 
* Shared Preferences
* Internal Storage
* External Storage
* SQLite database
Mobile app testing is the testing of applications on a device which mainly focuses on functions and features of the application.
 
Mobile Testing is the testing of the actual mobile device and focuses on mobile features like Call, SMS, Contacts, Media Player, inbuilt browsers, etc.
Android framework is a set of API’s using which the Android developers write code for the mobile apps. It contains the methods and classes to write the programming code.
 
Android framework includes a different set of tools to create image pane, text field, buttons, etc. It also includes “Activities” with which the user interacts and “Services”, which are the programs that run in the background. It is a package of different components like Intents, Broadcast Receivers, Content Providers, etc.
User navigates between different screen or app, it goes through different states in their lifecycle. So an activity lifecycle consists of 7 different methods of android.app.Activity class i.e :
 
onCreate() : In this state, the activity is created.
 
onStart() : This callback method is called when the activity becomes visible to the user.
 
onResume() : The activity is in the foreground and the user can interact with it.
 
onPause() : Activity is partially obscured by another activity. Other activity that’s in the foreground is semi-transparent.
 
onStop() : The activity is completely hidden and not visible to the user.
 
onDestroy() : Activity is destroyed and removed from the memory.
An Intent is an “intention” to do an action.  An intent is a messaging object you can use to request an action from another app component.
 
Methods are used to deliver intents to different components :
 
context.startActivity() : To start an activity
context.startService() : To start a service
context.sendBroadcast() : To deliver a broadcast
 
Types of Intent :
 
Implicit Intent : Implicit intent is when the target component is not defined in the intent and the android system has to evaluate the registered components based on the intent data.
 
Explicit Intent : Explicit intent is when an application defines the target component directly in the intent.
Activities are the part of the mobile app which the user can see and interact with.
 
For Example, if you open an SMS app which has multiple activities like create new SMS, add a contact from the address book, write the content in the SMS body, send SMS to the selected contact, etc.
 
Activity keeps a track of the following :
 
* Keeps track of what a user is currently looking for in an app.
* Keeps a track of previously used processes, so that the user can switch between ongoing process and previous process.
* It helps to kill the processes so that the user can return to their previous state

An activity is implemented as a subclass of Activity class as shown below :
 
Public class MyActivity extends Activity
{

}

 

Service is an Android component that runs in the background and acts independently. It does not provide any user interface.
 
Though the services are running behind the scene, a user can continue their work on different apps. Most of the time, the users are not aware of the services which are running in the background. These services allow the system to kill the process without interrupting the user’s ongoing work.
 
A service is implemented as a subclass of Service class :
 
Public class MainService extends Service
{

}

 

ANR stands for Application Not Responding. It is a notification or pop-up displayed by the Android platform whenever the application is performing too many functions at a time and if it is suddenly not responding for a long time to the user action.
Android supports four types of dialog boxes :
 
AlertDialog : It has a maximum of 3 buttons and sometimes AlertDialog includes checkboxes and Radio buttons to select the element.
ProgressDialog : It displays the progress bar or wheels.
TimePickerDialog : Using this dialog box, a user selects the Time.
DatePickerDialog : Using this dialog box, a user selects the Date