0
我能夠生成並顯示多個通知,所有通知都啓動相同的活動,但顯示的信息取決於附加到啓動活動。當我在我的應用程序中時,所有通知都能夠啓動Activity,但是當我處於應用程序之外時,只有一個能夠啓動Activity(我點擊第一個),其他人一旦點擊就不做任何事情(除了消失)。這是我生成通知的代碼。 「reqCode」代表唯一的數字。我的許多通知中只有一個是在我的應用程序之外開始一個活動
Resources r = getResources();
Intent i = new Intent(this, DisplaySearchTickerAlert_Activity.class);
i.putExtra(NewArticleNotification_Service.QUERY_TICKER, searchQuery);
PendingIntent pi = PendingIntent.getActivity(this, reqCode, i, 0);
Notification notification = new NotificationCompat.Builder(this)
.setTicker(r.getString(R.string.ticker_alert))
.setSmallIcon(android.R.drawable.ic_menu_call)
.setContentTitle(r.getString(R.string.ticker_alert))
.setContentText("Newly published for search term: " + "\""
+ searchQuery + "\"").setContentIntent(pi).setAutoCancel(true).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(reqCode, notification);
那麼爲什麼通知全部正常工作,並且當我在我的應用程序中時啓動相同的活動(具有不同的內容)我爲此活動啓動的模式是「標準」。那麼解決方案是什麼? – derek 2014-12-11 09:35:09