Android的活动周期:ONSTART() - >的onStop()可能吗? [英] Android Activity Lifecycle: onStart() -> onStop() possible?

查看:169
本文介绍了Android的活动周期:ONSTART() - >的onStop()可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的应用程序基础它说,在调用后,在ONSTART() - 活动周期的方法,无论是回调方法 onResume()的onStop()被调用。如果是一个正常的启动活动的系统调用的onCreate() ONSTART() onResume()。 但是否有人知道一个例子,其中 ONSTART() - 的onStop()是一个接一个执行

解决方案
  1. 从你的活动,开始另一项活动,是不是全屏幕(例如给它的android:主题=@安卓风格/ Theme.Dialog)。

    在这一点上你的第一个活动已在onPause()调用但不是的onStop(),因为它是不是在前面,但仍清晰可见。

  2. preSS回家。

    在这一点上的onStop()被调用你的第一个活动。

  3. 重新启动你的应用程序。

    在这一点上ONSTART()被调用你的第一个活动,但不onResume(),因为它仍然在它之上的非全屏幕活动。

  4. preSS回家。

    在这一点上的onStop()调用的第一个活动,而无需通过onResume()已经走了。

In the Android Application Fundamentals it says that after the call to the onStart()-method of the activity lifecycle either the callback method onResume() or onStop() is called. In case of an "normal" Start of an activity the system calls onCreate(), onStart(), onResume(). But does somebody know an example where onStart() - onStop() are executed one after another?

解决方案

  1. From your activity, start another activity that is not full-screen (for example give it android:theme="@android:style/Theme.Dialog").

    At this point your first activity has had onPause() called but not onStop() because it is not in the front but still visible.

  2. Press home.

    At this point onStop() is called for your first activity.

  3. Relaunch your app.

    At this point onStart() is called for your first activity, but not onResume() because it still has the non-full-screen activity on top of it.

  4. Press home.

    At this point onStop() is called on the first activity, without having gone through onResume().

这篇关于Android的活动周期:ONSTART() - >的onStop()可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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