all be healthy

The problem is this: at the entrance there is a certain list of objects that is formed in the service. When receiving this list, it is necessary to make notifications one for each position (from the same service).

I create notifications, I throw intents there, but when I click on an intent, the necessary activation opens and takes some kind of heresy from this intent.

Where am I wrong?

private void sendNotificationEarchNewItems(List<Map<String, Object>> newIrems) { final List<Map<String, Object>> locList = newIrems; final Handler uiHandler = new Handler(Looper.getMainLooper()); uiHandler.post(new Runnable() { @Override public void run() { for (Map map : locList) { final Context context = getApplicationContext(); final String idd = map.get("_id").toString(); final int NOTIF_ID = Integer.parseInt(idd.substring(0, 6)); final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(getApplicationContext(), ItemActivity.class); intent.putExtra("_id", idd); PendingIntent pIntent = PendingIntent.getActivity(thisContext, 0, intent, 0); final Notification notification = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(map.get("title").toString()) .setContentIntent(pIntent) .build(); notificationManager.notify(NOTIF_ID, notification); final RemoteViews contentView = notification.contentView; final int iconId = android.R.id.icon; Picasso.with(getApplicationContext()).load(map.get("mainImage").toString()).into(contentView, iconId, NOTIF_ID, notification); } } }); } 
  • once again analyzed the debugger. "_id" going to the intent is overwritten each time a new notification is created. It means that the entire list should be sent to the intent and the notification messages should be mapped. But how to catch a click on the notification? - baralgin1003

1 answer 1

At pendingintent put the same requesting codes. Everything worked with this edit.

  PendingIntent pIntent = PendingIntent.getActivity(thisContext, NOTIF_ID , intent, 0);