What is the difference between onPause() and onStop() of Android Activites?

No, if some activity comes into foreground, that doesn’t necessarily mean that the other activity is completely invisible. Consider the following case:

Activity with the theme Theme.Dialog

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);

Leave a Comment