1
我試圖顯示通知欄中元素的列表。現在我有一組通知,但是我點擊的每個通知都會將我帶到同一活動,即我無法存儲通知的位置。如何在android中知道通知的位置
這裏是我的代碼
if (list != null && !list.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(
"Coupon Received From "
+ list.get(i).merchantName)
.setContentText(
"Coupon Value : "
+ list.get(i).couponValue)
.setAutoCancel(true)
.setTicker("Coupon alert message from Kluebook")
.setVibrate(new long[] { 100, 250, 100, 250 });
Intent resultIntent = new Intent(context,
CouponDetailActivity.class);
resultIntent.putExtra("couponid",
list.get(i).couponid);
resultIntent.putExtra("position", list.get(i).i);
resultIntent.putExtra("branchid",
list.get(i).issuedBranchid);
PendingIntent resultPendingIntent = PendingIntent.getActivity(
context, 0, resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotifyMgr = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(i + 1, mBuilder.build());
}
} else {
System.out.println("+++++++++++ IT IS EMPTY +++++++++++++++ list");
}
}
如果我得到通知欄5周的通知,通知每一個需要我先通知活動。
我通過在待決意圖中保留'i'而不是'0'來解決問題 –