我在我的应用程序中有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