Android - onNewIntent is not called - singletop ac

2019-08-09 23:49发布

I have launcher A (activity A1) and application B (activities B1, B2 both singletop).

A1 -> B1 -> B2 -> A1 -> B2.

However onNewIntent wasn't called on activity B2, B2 did call direct onResume but not onNewIntent.

Launcher A : Activity A1:

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

I want:

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

But not:

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

Can someone helps me out? Thanks. (Debug on Android 4.4.2)

2条回答
该账号已被封号
2楼-- · 2019-08-10 00:13
onNewIntent(Intent intent)

is only called once before the activity is created. After that It will not call untill you destroy and recreate the activity... Please see the docs, It will more clarify you, http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)

查看更多
Evening l夕情丶
3楼-- · 2019-08-10 00:20

For onNewIntent(Intent intent) to be called, you must declare your activity's launchmode in the manifest as android:launchMode="singleTop" OR android:launchMode="singleTask"

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

查看更多
登录 后发表回答