diff options
| author | 2016-07-27 19:52:23 +0000 | |
|---|---|---|
| committer | 2016-07-27 19:52:23 +0000 | |
| commit | 23b91ca59cdaf96a791aeeb040f119501b6eea56 (patch) | |
| tree | 72690cbfd89d74223e960eb5a75a4e124498f518 | |
| parent | 255ad67b2e61c5ac407c5ef539275b4de99186b4 (diff) | |
| parent | bae260d909c4cff75ec3f888590f0840e1f40a5c (diff) | |
Docs: Used NotificationCompat.MediaStyle am: d3c609cbc1
am: bae260d909
Change-Id: Icff03d57f9efe571671f77bc2ba3f47a1ebd2e75
| -rw-r--r-- | docs/html/guide/topics/ui/notifiers/notifications.jd | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/docs/html/guide/topics/ui/notifiers/notifications.jd b/docs/html/guide/topics/ui/notifiers/notifications.jd index 6cd63f384a42..8c7e0864a2d9 100644 --- a/docs/html/guide/topics/ui/notifiers/notifications.jd +++ b/docs/html/guide/topics/ui/notifiers/notifications.jd @@ -886,35 +886,38 @@ method.</p> <h3 id="controllingMedia">Controlling Media Playback on the Lock Screen</h3> -<p>In Android 5.0 (API level 21) the lock screen no longer displays media controls -based on the {@link android.media.RemoteControlClient}, which is now deprecated. Instead, use the -{@link android.app.Notification.MediaStyle} template with the -{@link android.app.Notification.Builder#addAction(android.app.Notification.Action) addAction()} -method, which converts actions into clickable icons.</p> - -<p class="note"><strong>Note:</strong> The template and the -{@link android.app.Notification.Builder#addAction(android.app.Notification.Action) addAction()} -method are not included in the support library, so these features run in Android 5.0 and higher -only.</p> - -<p>To display media playback controls on the lock screen in Android 5.0, set the visibility -to {@link android.support.v4.app.NotificationCompat#VISIBILITY_PUBLIC}, as described above. Then add -the actions and set the {@link android.app.Notification.MediaStyle} template, as described in the -following sample code:</p> +<p> + In Android 5.0 (API level 21) the lock screen no longer displays media + controls based on the {@link android.media.RemoteControlClient}, which is + now deprecated. Instead, use the {@link + android.support.v7.app.NotificationCompat.MediaStyle} template with the + {@link + android.support.v4.app.NotificationCompat.Builder#addAction(android.support.v4.app.NotificationCompat.Action) + addAction()} method, which converts actions into clickable icons. +</p> + +<p> + To display media playback controls on the lock screen in Android 5.0, set + the visibility to {@link + android.support.v4.app.NotificationCompat#VISIBILITY_PUBLIC}, as described + above. Then add the actions and set the {@link + android.support.v7.app.NotificationCompat.MediaStyle} template, as described + in the following sample code: +</p> <pre> -Notification notification = new Notification.Builder(context) +Notification notification = new NotificationCompat.Builder(context) // Show controls on lock screen even when user hides sensitive content. - .setVisibility(Notification.VISIBILITY_PUBLIC) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setSmallIcon(R.drawable.ic_stat_player) // Add media control buttons that invoke intents in your media service .addAction(R.drawable.ic_prev, "Previous", prevPendingIntent) // #0 .addAction(R.drawable.ic_pause, "Pause", pausePendingIntent) // #1 .addAction(R.drawable.ic_next, "Next", nextPendingIntent) // #2 // Apply the media style template - .setStyle(new Notification.MediaStyle() - .setShowActionsInCompactView(1 /* #1: pause button */) - .setMediaSession(mMediaSession.getSessionToken()) + .setStyle(new NotificationCompat.MediaStyle() + .setShowActionsInCompactView(1 /* #1: pause button */) + .setMediaSession(mMediaSession.getSessionToken())) .setContentTitle("Wonderful music") .setContentText("My Awesome Band") .setLargeIcon(albumArtBitmap) |