0
我想在用戶從通知中調用應用程序時恢復主要活動,但此代碼正在重新創建主要活動。如何停止它?從通知調用應用程序重新創建活動
int mId=1;
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setContentTitle("My notification")
.setAutoCancel(true)
.setSmallIcon(R.drawable.twitter)
.setContentText("Hello World!")
.setNumber(15);
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.setAction(Intent.ACTION_MAIN);
resultIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(mId, mBuilder.build());
此外,我放置android:launchMode="singleTop"
我的主要活動在我的清單file.How我能解決這個問題?
[Android通知的可能重複啓動同一活動兩次](http://stackoverflow.com/questions/4333946/android-notification-launches-same-activity-twice) – Varun 2014-09-18 22:06:22
@Varun我試過了,但沒有奏效。 – 2014-09-18 22:07:36