How to use onResume()?

Zizou picture Zizou · Mar 27, 2013 · Viewed 217.6k times · Source

Can anyone give me an example that uses onResume() in Android?

Also, if I want to restart the activity at the end of the execution of another, which method is executed—onCreate() or onResume()?

And if I want to update data, how do I put it in onResume()?

Answer

Mr.Sandy picture Mr.Sandy · Mar 27, 2013

Any Activity that restarts has its onResume() method executed first.

To use this method, do this:

@Override
public void onResume(){
    super.onResume();
    // put your code here...

}