Default MediaStyled notifications to CATEGORY_TRANSPORT
This makes it easier to identify them later (e.g., for filtering).
The developer can always specify a different category if preferred.
Also fixed some javadoc related to setMediaSession()
Change-Id: I5f28514758218ff66fdbaa9fd37ccb19f12d4852
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 61ed631..97a9920 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3223,6 +3223,10 @@
* {@link #setShowActionsInCompactView(int...)} you can promote up to 2 actions to be displayed
* in the standard view alongside the usual content.
*
+ * Notifications created with MediaStyle will have their category set to
+ * {@link Notification#CATEGORY_TRANSPORT CATEGORY_TRANSPORT} unless you set a different
+ * category using {@link Notification.Builder#setCategory(String) setCategory()}.
+ *
* Finally, if you attach a {@link android.media.session.MediaSession.Token} using
* {@link android.app.Notification.MediaStyle#setMediaSession(MediaSession.Token)},
* the System UI can identify this as a notification representing an active media session
@@ -3235,9 +3239,9 @@
* .setSmallIcon(R.drawable.ic_stat_player)
* .setContentTitle("Track title") // these three lines are optional
* .setContentText("Artist - Album") // if you use
- * .setLargeIcon(albumArtBitmap)) // setMediaSession(token, true)
- * .setMediaSession(mySession, true)
- * .setStyle(<b>new Notification.MediaStyle()</b>)
+ * .setLargeIcon(albumArtBitmap)) // setMediaSession(token)
+ * .setStyle(<b>new Notification.MediaStyle()</b>
+ * .setMediaSession(mySession))
* .build();
* </pre>
*
@@ -3279,7 +3283,9 @@
public Notification buildStyled(Notification wip) {
wip.contentView = makeMediaContentView();
wip.bigContentView = makeMediaBigContentView();
-
+ if (wip.category == null) {
+ wip.category = Notification.CATEGORY_TRANSPORT;
+ }
return wip;
}