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