Issue
First of all, I've read the great explanation of how the activities start, suspend, resume and stop. It's fine but I have another problem.
The Activity lifecycle diagram in the Android reference tells that if I call another activity, onPause() will be called for the calling activity, and later, when the other activity is over--the caller will resume via onResume().
So if the first activity is Main and the other one is Other, the cycle would look like this (pseudocode):
Main.onCreate()
Main.onStart()
Main.onResume()
// Main is running... Then, the user clicks a button and Other comes in front.
Main.onPause()
Other.onCreate()
// Other's lifecycle goes here... Finally, the user returns back.
Main.onResume()
// Main is running again.
This is what the diagram tells. But my Main gets onStart() first, then onResume().
Why is that? Do I misunderstand something?
Solution
That is happening because your Main activity is totally disappearing from view, which triggers onStop, which triggers OnStart when you resume. If you only partially hid the view from your Main, you would only get onResume.
If you look at the diagram, between onPause and onStop, there is this "the activity is no longer visible"... that's what you are encountering.
For quick reference, the activity lifecycle graphic:
Answered By - Barak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.