Add deleteIntent

This commit is contained in:
tzugen 2021-04-21 17:14:05 +02:00
parent d3b94f3d4c
commit e4bf431cfe
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 4 additions and 0 deletions

View File

@ -673,6 +673,7 @@ public class MediaPlayerService extends Service
// Init
Context context = getApplicationContext();
MusicDirectory.Entry song = (currentPlaying != null) ? currentPlaying.getSong() : null;
PendingIntent stopIntent = getPendingIntentForMediaAction(context, KeyEvent.KEYCODE_MEDIA_STOP, 100);
// We should use a single notification builder, otherwise the notification may not be updated
if (notificationBuilder == null) {
@ -690,6 +691,9 @@ public class MediaPlayerService extends Service
// Add content intent (when user taps on notification)
notificationBuilder.setContentIntent(getPendingIntentForContent());
// This intent is executed when the user closes the notification
notificationBuilder.setDeleteIntent(stopIntent);
}
// Use the Media Style, to enable native Android support for playback notification