We provide complete mobile and web apps development solutions

Monday, September 3, 2012

Activity Life Cycle



Activities in the life cycle are managed as an activity stack. When a new activity is started, it is placed on the top of the stack.  It becomes the running activity.
The previous activity always remains below it in the stack, and will not come to the foreground until the new activity exits.
4       Stages of Activity:
1.       If an activity in the foreground of the screen (at the top of the stack), it is active or running.
  1. If an activity has lost focus but is still visible, it is paused. It saves the activity state, but can be killed by the system in extreme low memory situations.
  2. If an activity is completely occupied by another activity, it is stopped. It  retains all state and member information.
  3. If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish or simply killing the process.


Public class MainActivity extends Activity {
Public void onCreate(Bundle savedInstanceState) {
Super.onCreate(savedInstanceState);
}
Protected void onStart() {
Super.onStart();
// The activity is about to become visible.
}
Protected void onResume(){
Super.onResume();
// the activity has become visible
}
Protected void onPause(){
Super.onPause();
// Another activity is taking focus
}
Protected void onStop(){
Super.onStop();
//the activity is no longer visible
}
Protected void onDestroy(){
Super.onDestroy();
//the activity is about to be destroyed
}
}
The entire lifetime of an activity happends between the call to onCreate() and call to onDestroy().



0 coment�rios:

Post a Comment

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts