Answer: C 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>
Description:
Answer: C 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.
Description: A splash screen can be designed by using some alarms or timers, so that main screen will be displayed and splash screen will be destroyed after that many seconds. Eg: Candy Crush game shows a splash screen with "King" in the starting screen before going to the actual screen. While it shows that screen it does some background work also to start next heavy activity.
Answer: C both option 1 and 2 are correct.
Description:
Answer: A Save all those variables in onSaveInstanceState().
Description: These kind of variables are called as transient state of Activity. These will not be saved by Android, it is programmers duty. So save it in onSaveInstanceState().
Answer: C option 2 is true, so use it only for saving small transient states.
Description: onSaveInstanceState() function has to be used for saving small objects (transient states). If we want to save large objects use onRetainNonConfigurationInstance() function.
Answer: C No, because that function might not be called all the time.
Description: We have to save all DB updates on or before onPause() function of activity life cycle. Because this is the last guaranteed function to be called on all scenarios of an activity life cycle.
Note : If you save DB in onSaveInstanceState, then that function will not be called if user presses back button on the activity.
So it will end up in loosing all the database un saved data.
Answer: D we can use either option 1 or 2.
Description: onSaveInstanceState() function has to be used for saving small objects (transient states). If we want to save large objects use onRetainNonConfigurationInstance() function. Or else we can make that image as static, so that the image will be loaded only once.
More documentation :
onSaveInstanceState() function has to be used for saving small objects, not for heavy objects.
If you want to save heavy images on phone rotation, then use any of below techniques:
1. If you want to save large objects use onRetainNonConfigurationInstance() function.
2. Or else we can make that image as static, so that the image will be loaded only once. Meaning: On downloading an image from network, make it pointed by a static variable. If user rotates the phone, since android kills that activity and recreates it, just put a if condition check if that static variable is not null, then only download again. As you know static variables will be created only once, it will not download again.
But preferably go for 1st option.
Answer: C it will be started as a new task always.
Description: When we start a new activity from Notification, it is fresh starting point, so it has to be started as a new task. that's why when we are starting an activity from notification, we have to use FLAG_NEW_TASK in the intent.
Answer: C 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.
Description: FLAG_ACTIVITY_CLEAR_TOP :
If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent to onNewIntent() function.
Answer: D Android will save & restore UI states automatically, so programmer don't need to worry.
Description: Generally orientation changes will cause android to kill and recreate the activity. But all the UI states will be saved and restored by android automatically. But to do this programmer has to supply id for each view. Other than this programmer don't need to take any extra effort.
Note : Android will save and restore only UI states, not transient states (any variable values).