Reputation: 2142
I want to refresh the app screen whenever user minimizes the app and reopens it from background. The issue is that if i apply my logic in onStop method then it will be called in that case too when i open another activity on top of existing page when app is open. In iOS there is a method that informs them when app is re-entered from background but how can i achieve this in android?
Upvotes: 0
Views: 29
Reputation: 2568
You should use OnResume().
There is the famous graph taken from here that might help you.
If you would like to know if the OnResume()
is called after onStart or onPause()
, have a boolean flag in your activity like:
void onPause () {
bPaused = true;
}
void onResume() {
//check the bPaused member
if (bPaused == true){
bPaused = false; // reset the flag
//do what ever you want to do as the app was resumed
} else {
// we are entring this code after onStart and onPaused was not called yet.
}
}
Upvotes: 2