爲什麼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
實際上我從來沒有用過..但我發送數據的通知就像我說的方式..是否工作? –