From e4bf431cfef1ce9b563e739a61d7520fefb594c2 Mon Sep 17 00:00:00 2001 From: tzugen Date: Wed, 21 Apr 2021 17:14:05 +0200 Subject: [PATCH] Add deleteIntent --- .../java/org/moire/ultrasonic/service/MediaPlayerService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/service/MediaPlayerService.java b/ultrasonic/src/main/java/org/moire/ultrasonic/service/MediaPlayerService.java index a0046956..cb180138 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/service/MediaPlayerService.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/service/MediaPlayerService.java @@ -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