Question : Which of the following is not an Activity lifecycle call-back method?
1. onStart
2. onCreate
3. onPause
4. onBackPressed
Correct Answer : 4 Explanation: The Activity class defines the following call backs i.e. events. You don't need to implement all the callbacks methods. However, it's important that you understand each one and implement those that ensure your app behaves the way users expect.
Callback Description onCreate() This is the first callback and called when the activity is first created. onStart() This callback is called when the activity becomes visible to the user. onResume() This is called when the user starts interacting with the application. onPause() The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed. onStop() This callback is called when the activity is no longer visible. onDestroy() This callback is called before the activity is destroyed by the system. onRestart() This callback is called when the activity restarts after stopping it.
Question : Which method is used to close an activity?
1. Destroy()
2. Finish()
3. Stop()
4. Close()
Correct Answer : 2 Explanation: When calling finish() on an activity, the method onDestroy() is executed this method can do things like:
Dismiss any dialogs the activity was managing. Close any cursors the activity was managing. Close any open search dialog Also, onDestroy() isn't a destructor. It doesn't actually destroy the object. It's just a method that's called based on a certain state. So your instance is still alive and very well* after the superclass's onDestroy() runs and returns.Android keeps processes around in case the user wants to restart the app, this makes the startup phase faster. The process will not be doing anything and if memory needs to be reclaimed, the process will be killed
Question : Which of the following Activity life-cycle methods is called once the activity is no longer visible?
1. onStop
2. onPause
3. onDestroy
4. onHide
Correct Answer : 1 Explanation: The Activity class defines the following call backs i.e. events. You don't need to implement all the callbacks methods. However, it's important that you understand each one and implement those that ensure your app behaves the way users expect.
Callback Description onCreate() This is the first callback and called when the activity is first created. onStart() This callback is called when the activity becomes visible to the user. onResume() This is called when the user starts interacting with the application. onPause() The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed. onStop() This callback is called when the activity is no longer visible. onDestroy() This callback is called before the activity is destroyed by the system. onRestart() This callback is called when the activity restarts after stopping it.
1. In order to display a Ul defined in the XML layout file "main.xml", call the setContentView method of theActivity with the parameter string "main.xml".
2. There is no distinction between implementation of the layout definition by code, or by XML layout file.
3. In an Eclipse project using the ADT plugin, the XML layout file is found in the /res/layout directory.
4. Layout information written in the XML layout file will be converted into code by the Android platform whenthe screen is displayed.