简体   繁体   English

活动开始另一个活动。 确保第一个活动的onPause将在第二个活动的onResume之前调用

[英]Activity starting another activity. Guarantee that the first activity's onPause will be called before second's onResume

I have an Activity A and Activity B. Activity A starts Activity B. 我有一个活动A和一个活动B。活动A启动了活动B。

Is there a guarantee that A's onPause() will always be called before calling B's onResume()? 是否可以保证在调用B的onResume()之前总是先调用A的onPause()?

This is related to this entry 这与此条目有关

Found the answer here : 这里找到答案:

When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here. 当活动B在活动A之前启动时,将在A上调用此回调。在A的onPause()返回之前,将不会创建B,因此请确保此处不要做任何冗长的操作。

onPause () onPause()

When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns , so be sure to not do anything lengthy here 当活动B在活动A之前启动时,将在A上调用此回调。 在A的onPause()返回之前将不会创建B ,因此请确保此处不要做任何冗长的操作

http://developer.android.com/reference/android/app/Activity.html#onPause() http://developer.android.com/reference/android/app/Activity.html#onPause()

Yes. 是。 Activity A 's onPause() will be called before passing to Activity B 's onResume() if the navigation is not the first time. 如果不是第一次导航,则将在传递给Activity BonResume()之前调用Activity AonPause() If navigating to Activity B is for the first time, then Activity B 's onCreate() will be called after Activity A's onPause() . 如果是第一次导航到Activity B ,则将在活动A的onPause()之后调用Activity BonCreate() onPause() Take a look at Activity's Lifecycle for clear understanding. 请看一下Activity的生命周期以了解清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 活动的onPause和onResume在启动后被调用,无缘无故 - Activity's onPause and onResume being called after starting, for no reason 第一个活动的onPause在连续启动两个活动时未调用,而第二个活动具有半透明主题 - first activity's onPause not called when start two activity continuously and the second activity with translucent theme onPause()在我的活动中被调用。 然后,当回到顶部时,onResume()永远不会被调用 - onPause() gets called on my activity. Then, when brought back to the top, onResume() never gets called onPause / onResume活动问题 - onPause/onResume activity issues 我的活动的onPause / OnResume方法每分钟都会被无故调用一次 - My activity's onPause/OnResume methods are called once every minute for no reason 启动另一个全屏活动时未调用Activity的onStop() - Activity's onStop() not called when starting another full screen Activity onResume中的动画阻止了另一个活动的onDestroy - Anmation in onResume blocked another activity's onDestroy 开始另一个应用程序的活动 - Starting another app's activity 启动活动后立即调用OnPause和OnStop() - OnPause and OnStop() called immediately after starting activity 如果显示非页内广告,则Activity中不会调用onResume()和onPause() - If show Interstitial ad, onResume() and onPause() not called within Activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM