private void pushlocalnotificationsoffers(String noTitle, String notText, int p) {
notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_logo_rush_for_less)
.setLargeIcon(getBitmapFromURL(shopsInfos.get(p).getIcon()))
.setContentTitle(noTitle)
.setContentText(notText);
final SharedPreferences.Editor editor = sharedpref.edit();
editor.putString("shopid", shopsInfos.get(p).getId());
editor.apply();
for (int z=0;z<producstInfos.size();z++) {
int requestcode=0;
notificationIntent = new Intent(MyService.this, Display_Clicked_Offer_Info.class);
notificationIntent.putExtra("IDITEM", producstInfos.get(z).getId());
notificationIntent.putExtra("CATID", producstInfos.get(z).getCat_id());
notificationIntent.putExtra("shopname", producstInfos.get(z).getShopname());
notificationIntent.putExtra("itemname", producstInfos.get(z).getProductname());
notificationIntent.putExtra("oldPrice", producstInfos.get(z).getPrice());
notificationIntent.putExtra("newPrice", producstInfos.get(z).getOffers());
notificationIntent.putExtra("itemsavailableofproducts", producstInfos.get(z).getQuantity());
notificationIntent.putExtra("imageBigProduct", producstInfos.get(z).getUrlimage());
notificationIntent.putExtra("shopIcon", producstInfos.get(z).getUrl_shop_icon());
notificationIntent.putExtra("details", producstInfos.get(z).getDetails());
notificationIntent.putExtra("shopid", producstInfos.get(z).getShop_iD());
notificationIntent.putExtra("starttime", producstInfos.get(z).getStarting_time());
notificationIntent.putExtra("endtime", producstInfos.get(z).getEnding_time());
Log.e("notiINFO", "product at index [" + z + "] id item " + producstInfos.get(z).getId() + " cat id" + producstInfos.get(z).getCat_id() + " shop name " + producstInfos.get(z).getShopname() + " item name "
+ producstInfos.get(z).getProductname() + " old price" + producstInfos.get(z).getPrice() + " new price" + producstInfos.get(z).getOffers() + " items available " + producstInfos.get(z).getQuantity() +
" img prod " + producstInfos.get(z).getUrlimage() + " shop icon " + producstInfos.get(z).getUrl_shop_icon() + " details" + producstInfos.get(z).getDetails() +
" shop id" + producstInfos.get(z).getShop_iD() + " start time" + producstInfos.get(z).getStarting_time() + " end time" + producstInfos.get(z).getEnding_time());
contentIntent = PendingIntent.getActivity(getApplicationContext(), z, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.setContentIntent(contentIntent);
notification = notificationBuilder.build();
}
currentNotificationID++;
notificationId = currentNotificationID;
if (notificationId == Integer.MAX_VALUE - 1)
notificationId = 0;
Log.e("NotificationsID===",""+notificationId);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notificationManager.notify(notificationId, notification);
Vibrator vibrator = (Vibrator) (getApplicationContext()).getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(2000);
}
每个通知都有不同的分配数据,但我收到所有通知的数组中最后一个索引的数据。 并且分配的数据没有错,我可以在日志中看到不同的数据