我有一個Android活動,在狀態欄中放置一個通知。選擇通知將啓動我的主要活動。問題是這個PendingIntent
總是開始我的活動「MyappMain」的新實例。因此,當我通過點擊通知啓動我的應用程序時,我得到一個MyappMain的新實例,然後我必須逐個完成它們(如果我在通知上單擊多次)。PendingIntent恢復活動
Intent notificationIntent = new Intent(this, MyappMain.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(HELLO_ID, notification);