I'm trying to show the X on the MediaStyle Notification Android P. I see a lot of posts basically saying this won't work on API 21 and higher I think but here is screenshot of an app showing it:
I've tried this code below but it doesn't show it:
Notification notification = new NotificationCompat.Builder(getApplicationContext(), TESTID)
.setSmallIcon(R.drawable.ic_launcher_background)
.setContentTitle("Track title")
.setContentText("Artist - Album")
.addAction(R.drawable.ic_fast_forward_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_fast_forward_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_fast_forward_black_24dp, "fwd", pi)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.vectors_525058875))
.setAutoCancel(false)
.setStyle(new MediaStyle()
.setMediaSession(mediaSessionCompat.getSessionToken()).setShowCancelButton(true).setCancelButtonIntent(pi))
.build();
notificationManager.notify(300, notification);
from How can I get the X button for stopping on the media style notification on Android P?

No comments:
Post a Comment