when I'm clicking the notification it self and the action button it does the same, I want to differentiate between them, I want the button do something and when I click the notification is self something else, here is my code-
Intent intent = new Intent(this, NotificationView.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setTicker(getString(R.string.notificationticker))
.setContentTitle(getString(R.string.notificationtitle))
.setContentText(yeah)
.addAction(R.drawable.ic_favorite, getString(R.string.azor), pIntent)
.setContentIntent(pIntent)
.setAutoCancel(true);
NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationmanager.notify(0, builder.build());
Pass different PendingIntents to addAction and setContentIntent.
Currently they both use the same pIntent instance.
If you want them both to launch the same activity but do something different, you can add extra's to the Intent used to make the pending intent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With