【发布时间】:2016-11-17 14:29:18
【问题描述】:
为什么通知中的Intent 为空?
Intent resultIntent = new Intent(context, myclass.class);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
Bundle extras=new Bundle();
extras.putString("key","value");
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
context,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
NotificationCompat.Builder n = new NotificationCompat.Builder(context)
.setContentTitle("test")
.setContentText(text)
.setSound(sound)
.setContentIntent(resultPendingIntent)
.setAutoCancel(true)
.setExtras(extras)
.setSmallIcon(android.R.drawable.ic_media_play);
NotificationManager notificationManager = (NotificationManager) context.getSystemService((context.getApplicationContext().NOTIFICATION_SERVICE));
notificationManager.notify(0, n.build());
}
但是在onStart() myclass 中,当我调用getintent().getExtras() 时,结果是null,为什么?
我如何从通知 Intent 中getExtras()?
【问题讨论】:
标签: android android-intent notifications