I am starting Android Programming!
Can anyone give me a simple explanation about Android's onResume onPause event?
When does it occur and when does the activity get destroyed and free memory? Thanks!
I am starting Android Programming!
Can anyone give me a simple explanation about Android's onResume onPause event?
When does it occur and when does the activity get destroyed and free memory? Thanks!
Your application will be destroyed upon the onDestroy() method; this is generally called the last activity in your application has left the stack.
onPause() and onResume() I believe are called when another activity is placed on top of the current activity in the stack - onPause() would be called once said activity loses focus, and onResume() would be called once it gains focus again.
The below image should explain things better. Good luck!
when lauch: onCreate onStart onResume
when press HOME: onPause onStop
when restart through menu(or lastest shortcut): onRestart onStart onResume
when press BACK: onPause onStop onDestory
when change orientation:onPause onStop onDestory then onCreate onStart onResume
watch the Activity life circle for more details
It's recommend to save status in onPause