-2

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!

AJ Naidas
  • 1,424
  • 7
  • 25
  • 47

2 Answers2

1

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!

enter image description here

TJ Biddle
  • 6,024
  • 6
  • 40
  • 47
1

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

JohnCookie
  • 661
  • 3
  • 7