为什么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());
}
但MyClass中的onStart()
当我打电话getintent().getExtras()
结果是空,为什么呢? 如何才能从getExtras()
通知Intent?
确定,但又是什么在NotificationCompat.Builder .setExtras(演员),以及如何获得它? – spyker10
实际上我从来没有用过..但我发送数据的通知就像我说的方式..是否工作? –