From android doc here http://developer.android.com/reference/android/app/Activity.html,
it said 'Activity comes into foreground' will call onPause()
, and 'Activity is no longer visible' will call onStop()
.
Isn't 'Activity comes into foreground' same as 'Activity is no longer visible'? Can you please tell me what is the difference between them?
No, if some activity comes into foreground, that doesn't necessarily mean that the other activity is completely invisible. Consider the following case:
Here we see both activities at the same time. The first activity with the fields is obscured by another activity, and the user can no longer interact with it. However, it is still visible with all the resulting consequences.
That leaves a question which activity is considered fully opaque and covering the whole screen and which isn't. This decision is based on the window containing the activity. If the window has a flag windowIsFloating
or windowIsTranslucent
, then it is considered that the activity doesn't make the underlying stuff invisible, otherwise it does and will cause onStop()
to be called. The relevant code can be found in com.android.server.am.ActivityRecord
:
fullscreen = ent != null && !ent.array.getBoolean(
com.android.internal.R.styleable.Window_windowIsFloating, false)
&& !ent.array.getBoolean(
com.android.internal.R.styleable.Window_windowIsTranslucent, false);