summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java
index dc03f80..94ac023 100644
--- a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java
+++ b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java
@@ -279,7 +279,6 @@ public class MediaNotification extends BroadcastReceiver {
.setColor(mNotificationColor)
.setSmallIcon(R.drawable.ic_notification)
.setVisibility(Notification.VISIBILITY_PUBLIC)
- .setOngoing(true)
.setUsesChronometer(true)
.setContentTitle(description.getTitle())
.setContentText(description.getSubtitle())
@@ -343,6 +342,9 @@ public class MediaNotification extends BroadcastReceiver {
updatePlayPauseAction();
+ // Make sure that the notification can be dismissed by the user when we are not playing:
+ mNotificationBuilder.setOngoing(mPlaybackState.getState() == PlaybackState.STATE_PLAYING);
+
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
}