Android-onNewIntent不被称为-ssingletop活动



我有启动器A(活动A1(和应用程序B(活动B1、B2都是单线程(。

A1->B1->B2->A1->B2。

然而,在活动B2上没有调用onNewIntent,B2直接调用了onResume,但没有调用onNew Intent。

启动器A:活动A1:

Intent app_B = getPackageManager().getLaunchIntentForPackage(PACKAGE_B);
startActivity(app_B);

我想要:

A1 -> B1 -> B2 -> A1 -> B2.onNewIntent(Intent intent)

但不是:

A1 -> B1 -> B2 -> A1 -> B2.onResume() 

有人能帮我吗?谢谢(在Android 4.4.2上调试(

onNewIntent(Intent intent)

在创建活动之前只调用一次。在那之后,它不会调用,直到你破坏并重新创建活动。。。请看文档,它会让你更清楚,http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Interent(

要调用onNewIntent(Intent Intent(,必须在清单中将活动的启动模式声明为android:launchMode="singleTop"android:launchMode="singleTask"

http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode

最新更新