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

后端 未结 8 1193
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 07:33

From android doc here http://developer.android.com/reference/android/app/Activity.html, it said \'Activity comes into foreground\' will call onPause(), and \'Ac

8条回答
  •  情书的邮戳
    2020-12-02 07:46

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

提交回复
热议问题