diff options
author | Renato Mangini <mangini@google.com> | 2014-11-07 18:56:34 -0800 |
---|---|---|
committer | Renato Mangini <mangini@google.com> | 2014-11-07 18:56:34 -0800 |
commit | dce3ccc533270340f57223a7c2685947762cfcbb (patch) | |
tree | 1ce87db2dcf8a1a9b958c9ffc5fe09952051351b | |
parent | 372eb5f8210ae554e2e4c08efae429b2f03b994f (diff) | |
download | demos-dce3ccc533270340f57223a7c2685947762cfcbb.tar.gz |
Allow notification to be dismissed when not playing
Bug: 18282868
Change-Id: I1716feaf0d0f42184bcd500b4860d92630a2c525
-rw-r--r-- | MusicDemo/src/main/java/com/example/android/musicservicedemo/MediaNotification.java | 4 |
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()); } |