Android notification .addAction deprecated in api 23

Instead of this one:

addAction (int icon, CharSequence title, PendingIntent intent)

This method was deprecated in API level 23.

Use:

addAction (Notification.Action action)

It’s all in the developer docs!

So to use this:

first build your action with the NotificationCompat.Action.Builder

NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_prev, "Previous", prevPendingIntent).build();

Note: Use NotificationCompat.Action

And than add it to your notification:

yournotification.addAction(action);

Leave a Comment