I am little confused between the life cycle of two activities.
Suppose I have Activity A and Activity B.
B is called From A i.e A ----> B
.
Now currently B
is on the screen and I pressed back button. Here I want know:- is there any memory still available for B
(Active) or B
's memory is flushed(Inactive).
This is an override function called when the user presses the back button on an Android device. It has great implications on the activity lifecycle of the application. The official documentation states that onBackPressed() method is called when the activity has detected the user's press of the back key.
Activity-lifecycle concepts To navigate transitions between stages of the activity lifecycle, the Activity class provides a core set of six callbacks: onCreate() , onStart() , onResume() , onPause() , onStop() , and onDestroy() . The system invokes each of these callbacks as an activity enters a new state.
1. onCreate(): In this state, the activity is created. 2. onStart(): This callback method is called when the activity becomes visible to the user.
If you hit the back button, then your Activity is finished and is destroyed, always resulting in a call to onDestroy().
Suppose there is an activity A, from which you launch activity B. If, while in activity B, you hit the back button, you are popping activity B off the stack and B will not be in the activity stack any longer.
Whenever you push an activity to the stack, onCreate
is called, and if you press back button, onDestroy
is called, which means that the activity is flushed away.
Please visit my blog for further information: http://upadhyayjiteshandroid.blogspot.in/2013/02/android-lifecycle.html
please visit for more
http://developer.android.com/guide/components/tasks-and-back-stack.html
http://developer.android.com/training/basics/activity-lifecycle/starting.html
The following activity call back methods are called, after pressing back button.
onPause()
onStop()
onDestroy()
The activity is destroyed.
And it recreates when launched again. These are the callback methods when it launches again.
onCreate()
onStart()
onResume()
I know the answer is been accepcted, still if this helps someone I am putting it.
When app is opening for the first time, by clicking the Icon
onCreate()
onStart()
onResume()
When home button is pressed
onPause()
onStop()
when app is again opened by clicking the app icon or launched from recent
onRestart()
onStart()
onResume()
when app is opened and then back button is pressed
onPause()
onStop()
onDestroy()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With