I need to implement the buttons under the notification.

I have 2 Samsung S5 and Meizu MX5

The push that I get on the Meizu MX5 looks like this

enter image description here

The push that I get on the Samsung S5 looks like

enter image description here

Here is my code

 public void With_buttons(View view) { Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_android_black_24dp); Intent resultIntent = new Intent(this, ResultActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(ResultActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification.Builder(this) .setVisibility(Notification.VISIBILITY_PUBLIC) .setSmallIcon(R.drawable.ic_android_black_24dp) .setContentTitle("Wonderful music") .setContentText("My Awesome Band") .setLargeIcon(icon) .addAction(R.drawable.ic_android_black_24dp, "Previous", resultPendingIntent) // #0 .addAction(R.drawable.ic_android_black_24dp, "Pause", resultPendingIntent) // #1 .addAction(R.drawable.ic_android_black_24dp, "Next", resultPendingIntent) // #2 .build(); mNotificationManager.notify((int) System.currentTimeMillis(), notification); } 

Why is this difference? I expect to see the buttons on the Samsung, but they are not ...

What am I doing wrong?

  • These buttons do not work with all versions of the OS. The second option, apparently too old. - Yuriy SPb
  • Samsung S5 not that old, but rather Samsung has cut something out of the system when porting :) - Eugene Krivenja
  • @YuriySPb On the contrary, Samsung is running at 5.1 and a meuse at 5.0 - Aleksey Timoshchenko

1 answer 1

Use NotificationCompat and remember that ActionButtons only work since Android 4.1

Addition
Try the S5 standard shell instead of the Samsung handicraft https://play.google.com/store/apps/details?id=com.google.android.launcher

Supplement 2
Still recommend for Samsung to use a non-zero value of the PendingIntent parameter for PendingIntent

 PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(1, PendingIntent.FLAG_UPDATE_CURRENT); 
  • I work with the version not lower than 5.0 ... NotificationCompat did not help ... It’s very strange of course ( - Aleksey Timoshchenko
  • So you need to write letters of thanks to Samsung :) - Eugene Krivenja
  • See addition to answer - Eugene Krivenja
  • Yes, but I'm not going to ask each user of my application to change the interface)) I thought maybe there was some standard solution ... - Aleksey Timoshchenko
  • You can draw your layout with buttons and add it to setContent (RemoteViews views) - miha_dev