Академический Документы
Профессиональный Документы
Культура Документы
7. What is the latest version of android? Can you tell me what is the
new concepts added in this version?
Ans:- Latest version of android is Android O.
(a) onCreate:
The system calls this when creating your activity.
You should initialize the essential components of your activity.
Eg:- setContentView()
Using findViewById(), to programatically interact witht the widgets
in the UI
calling managedQuery
You can call finish()
If you want any thread running in the background to download
DATA, you can do it here. This has to be deleted in onDestroy().
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.
(b) onStart:
Called after onCreate(Bundle) or after onRestart() followed by
onResume().
You can register a BroadCastReceiver in onStart() to monitor
changes that impact your UI, You have to unregister it in onStop().
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.
(c) onResume:
Called after onRestoreInstanceState(Bundle), onRestart() or
onPause().
Begin animations, open exclusive-access devices(such as the
camera).
(d) onPause:
Called as part of the activity lifecycle when an activity is going into
the background.
The counterpart to onResume().
B will not be created until A's onPause() returns.
Save all your persistent data here.
Good place to do things like stop animations to make switching to
the other activity as soon as possible.
Close your camera here if it is opened.
If device goes to sleep or some dialog is displayed, then it will go to
onPause().
(e) onDestroy:
Perform any final cleanup before an activity is destroyed.
Do not count on this method being called as a place for saving data!
This method is usually implemented to free resources like threads
that are associated with an activity.
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.
(f) onStop:
Called when you are no longer visible to the user.
You will next receive either onRestart(), onDestroy().
This method may never be called, in low memory situations.
Derived classes must call through to the super class's implementation
of this method. If they do not, an exception will be thrown.
(g) onRestart:
Called after onStop() when the current activity is being re-displayed
to the user.
It will be followed by onStart() and then onResume().
If you have deactivated any cursor in onStop(), call managedQuery()
again.
11. What is difference between persistent data and transient data, give
one example. Also tell me which activity life cycle function I need to
use to save them?
Ans:- Persistent data is permanent data that we store Eg:- In database
tables, and transient data is logical data that we use in programming logic.
Persistent means permanent and transient is temporary.