我的通知顯示方法:獲取通知的意圖羣衆演員
public static void ShowNotification(int id, String NotifFirstText,
String NotifTitle, String NotifeText, int notificon, long when) {
try {
Context context = ApplicationClass.context;
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
int icon = notificon;
CharSequence notiText = NotifFirstText;
long meow = when;
Notification notification = new Notification(icon, notiText, meow);
CharSequence contentTitle = NotifTitle;
CharSequence contentText = NotifeText;
Intent notificationIntent = new Intent();
String mPackage = "mypackage";
String mClass = ".ActivityShow";
notificationIntent.setComponent(new ComponentName(mPackage,
mPackage + mClass));
notificationIntent.putExtra("id", id);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
notification.flags = Notification.DEFAULT_LIGHTS
| Notification.FLAG_AUTO_CANCEL
| Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
PendingIntent contentIntent = PendingIntent.getActivity(G.context,
0, notificationIntent,0);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentIntent);
int SERVER_DATA_RECEIVED = id;
notificationManager.notify(SERVER_DATA_RECEIVED, notification);
} catch (Exception e) {
e.printStackTrace();
}
}
,這我的活動代碼:
if (getIntent().getExtras() != null) {
Toast.makeText(getBaseContext(),
getIntent().getExtras().getInt("id") + "", Toast.LENGTH_LONG).show();
}
我創建了多個通知,併爲所有這些設置不同的ID,但是當我點擊在每個通知我給同一個ID ...
如何解決這個問題?