我在我的應用程序中有2個活動,我希望活動X彈出一個通知 - 一旦它的點擊活動Y打開並從通知中讀取參數。如何在通知內傳遞額外信息?
所以我寫了這一點:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
CharSequence tickerText = NOTIFY_TICKER_NAME;
long when = System.currentTimeMillis();
Notification notification = new Notification(R.drawable.icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, PopTask.class);
notificationIntent.putExtra("task", "http://www.google.com");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1, notification);
問題是,當我嘗試讀取演員 - 我得到空。
我該怎麼辦?
感謝
THX使用
PendingIntent.FLAG_UPDATE_CURRENT
!這是我的缺失環節,使他們工作! :-)投了! – 2014-06-04 23:58:15真的很奇怪的修復,但感謝它的工作。 – Neil 2014-10-14 11:34:00