0
我无法恢复活动。Android意图 - 未恢复活动
这里是发生了什么:
活动A调用活动B:
Intent intent = new Intent(A.this, B.class);
startActivity(intent);
然后活动B设置一个通知,并调用活动答:
Intent intent = new Intent(this, MrpCastPlayerActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
intent, 0);
android.support.v4.app.NotificationCompat.Builder notif = new NotificationCompat.Builder(this);
notif.setContentIntent(pendingIntent)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("TITLE")
.setContentText("CONTENT")
.setAutoCancel(true);
notif.setOngoing(true);
Notification notification = notif.build();
NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationmanager.notify(0, notification);
Intent intent2 = new Intent(B.this, A.class);
startActivity(intent2);
的问题是当我点击通知时,它会打开活动B,但它不叫onResume
它叫onCreate
。 如果我使用moveTaskToBack(true)
,而不是启动intent2
,则调用onResume
。 看来,活动B完成时,我用intent2
打开活动A。
是否有避免这种情况?
“它打开活动B,但它不恢复它“ - 你能提供更多的信息在这 – Libin
@利宾它打开活动,但不呼吁onResume,它的调用onCreate –
你可以发布你的清单吗? Activity B android:launchMode应该是“singleTop” – Libin