在onPause和的onStop之间的差异() [英] Difference between onPause and onStop()

查看:186
本文介绍了在onPause和的onStop之间的差异()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Android电子文档这里<一href="http://developer.android.com/reference/android/app/Activity.html">http://developer.android.com/reference/android/app/Activity.html, 它说:活动进入前台'会叫的onPause(),和活动不再可见会叫的onStop()。

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.

这使得该活动被认为是完全不透明的,覆盖整个屏幕,其中一个问题是没有的。这一决定是基于含有活性的窗口上。如果窗口有一个标志 windowIsFloating windowIsTranslucent ,则认为该活动不会使底层的东西看不见的,否则它并会导致的onStop()被调用。有关code中可以找到 com.android.server.am.ActivityRecord

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

这篇关于在onPause和的onStop之间的差异()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆