Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android interview questions and answers

1
What is Manifest file?if we have two java files A.java and B.java in your source folder which one opens first and why?
  1. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.
    
    The activity which is having the following Intent Filter will be executed first:
    <intent-filter>
            <action android:name="android.intent.action.FIRST" />
            <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
  2. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.
    
    The activity which is having the following Intent Filter will be executed first:
    <intent-filter>
            <action android:name="android.intent.action.ONE" />
            <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
  3. Manifest files says the capabilities of your application and number of components in your application. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.
    
    The activity which is having the following Intent Filter will be executed first:
    <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
  4. None are correct
Show Answer
Share Facebook gmail Twitter
2
What is Splash screen or splash activity?
  1. Splash is a receiver in android that will be triggered after every 10 minutes.
  2. Splash is used in camera application for turning on camera's flash.
  3. Splash screen is an activity that will be shown generally as the initial screen while starting your application. This screen will be used to showcase your company's logo and other app related and company related basic information. Generally splash screen will be displayed for few seconds before going to main screen of the project.
  4. None are correct
Show Answer
Share Facebook gmail Twitter
3
Where do you write intent filters and Why?
  1. Intent-Filters are always in AndroidManifest.xml because the Android System uses intent filters, in order to find a suitable component to handle the intent. An Intent Filter defines the intent that a component can respond to. 
  2. We can have intentfilters in java code also in case of dynamic broadcast receivers.
  3. both option 1 and 2 are correct.
  4. In styles.xml because android system uses intent filter to determine for which activity which style need to be loaded.
Show Answer
Share Facebook gmail Twitter
4
How to save transient states in activity life cycle? eg: If I am using some variables, which will change based on my activities life cycle, then where should I save those variables, in case of configuration changes?
  1. Save all those variables in onSaveInstanceState().
  2. Save it using onRetainNonConfigurationInstance function.
  3. Save those variables in onPause.
  4. Android will save & restore all these variables, so programmer don't need to worry.
Show Answer
Share Facebook gmail Twitter
5
Can I use onSaveInstanceState for saving all my transient states?
  1. Yes, that function is meant for it.
  2. You should not use it for saving very large objects as it might take time to serialize and de-serialize it.
  3. option 2 is true, so use it only for saving small transient states.
  4. none of the above.
Show Answer
Share Facebook gmail Twitter
6
Can I save my database updates in onSaveInstanceState() of activity life cycle ?
  1. Yes, you can save, but make sure that it will not take too much of time.
  2. Yes, we can save database of any size in that function.
  3. No, because that function might not be called all the time.
  4. none of the above.
Show Answer
Share Facebook gmail Twitter
7
If some heavy images are downloaded from internet in onCreate() of an Activity, then where to save them in case of configuration changes (rotating the phone)?
  1. Use a static variable to point to that image, so that it will not be killed on activity death.
  2. Use onRetainNonConfigurationInstances() function to save it.
  3. Save that image in some file or DB and retrieve it in onCreate().
  4. we can use either option 1 or 2.
Show Answer
Share Facebook gmail Twitter
8
When starting an activity from a notification, will it start as new task or old task?
  1. Neither. it will be started as a system in Notification Manager task.
  2. It will be started in the old task, which has given pending intent to Notification Manager
  3. it will be started as a new task always.
Show Answer
Share Facebook gmail Twitter
9
What does the flag FLAG_ACTIVITY_CLEAR_TOP do here in below android code?
Assume that activities in the stack are A->B->C->D. Code is currently running in activity 'D'. Now what will happen in this scenario?

Intent in = new Intent(this, B.class);
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(in);
  1. It will start one more instance of Activity 'B' on top of activity 'D'. So it will look like A->B->C->D->B..
  2. It will not launch one more instance of Activity 'B' on top of activity 'D'. Instead this will send a new intent to onNewIntent() function of activity 'B' and B will come on top of D. so it will look like A->C->D->B.
  3. It will not launch one more instance of Activity 'B' on top of activity 'D'. Instead this will send a new intent to onNewIntent() function of activity 'B' and Activities C, D will be destroyed automatically.. so it will look like A->B.
  4. It will launch new instance of activity 'B' in a different task. so total two tasks are available now. task 1: A->B->C->D and task 2: B.
Show Answer
Share Facebook gmail Twitter
10
If activity is forcefully closed by Android system due to screen orientation change, then how to save UI states?
  1. Save all your UI stats in onSaveInstanceState().
  2. Save all your UI states using onRetainNonConfigurationInstance function.
  3. Save all your UI states in onPause.
  4. Android will save & restore UI states automatically, so programmer don't need to worry.
Show Answer
Share Facebook gmail Twitter
Read more papers :