2
通知および送信データを表示するには、次のコードを使用しますが、他のアクティビティではgetExtras()
はnull
を返します。どうして?なぜAndroidの通知の意図で余分なデータ(整数)が送信されないのですか?
int notificationID = 1;
NotificationManager nm = (NotificationManager) getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
Intent i = new Intent(getApplicationContext(), DownlodResult.class);
i.putExtra("notificationID", 1);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, i, 0);
CharSequence tickerText = "There are updates !";
long when = System.currentTimeMillis();
int icon = R.drawable.ic_launcher;
Notification notification = new Notification(icon,tickerText,when);
CharSequence contentTitle = "There are updates";
CharSequence contentText = "Please click here to view it";
notification.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
notification.vibrate = new long[] { 100, 250, 100, 500}; // Needs vibrate permissions
nm.notify(notificationID, notification);
これは受け入れられる回答である必要があります。私はそれを回避するために多くの時間を節約しました。 – haze4real