Notification.MediaStyle
public
static
class
Notification.MediaStyle
extends Notification.Style
| java.lang.Object | ||
| ↳ | android.app.Notification.Style | |
| ↳ | android.app.Notification.MediaStyle | |
|
|
Notification style for media playback notifications.
In the expanded form, bigContentView, up to 5
Notification.Actions specified with
addAction will be
shown as icon-only pushbuttons, suitable for transport controls. The Bitmap given to
setLargeIcon() will be
treated as album artwork.
Unlike the other styles provided here, MediaStyle can also modify the standard-size
contentView; by providing action indices to
setShowActionsInCompactView(int) you can promote up to 3 actions to be displayed
in the standard view alongside the usual content.
Notifications created with MediaStyle will have their category set to
CATEGORY_TRANSPORT unless you set a different
category using setCategory().
Finally, if you attach a MediaSession.Token using
setMediaSession(MediaSession.Token),
the System UI can identify this as a notification representing an active media session
and respond accordingly (by showing album artwork in the lockscreen, for example).
Starting at Android O any notification that has a
media session attached with setMediaSession(MediaSession.Token) will be colorized.
You can opt-out of this behavior by using setColorized(boolean).
To use this style with your Notification, feed it to
setStyle(android.app.Notification.Style) like so:
Notification noti = new Notification.Builder()
.setSmallIcon(R.drawable.ic_stat_player)
.setContentTitle("Track title")
.setContentText("Artist - Album")
.setLargeIcon(albumArtBitmap))
.setStyle(new Notification.MediaStyle()
.setMediaSession(mySession))
.build();
See also:
Summary
Inherited fields |
|---|
android.app.Notification.Style
|
Public constructors | |
|---|---|
Notification.MediaStyle()
|
|
Notification.MediaStyle(Notification.Builder builder)
This constructor was deprecated
in API level 24.
use |
|
Public methods | |
|---|---|
Notification.MediaStyle
|
setMediaSession(MediaSession.Token token)
Attach a |
Notification.MediaStyle
|
setShowActionsInCompactView(int... actions)
Request up to 3 actions (by index in the order of addition) to be shown in the compact notification view. |
Inherited methods | |
|---|---|
android.app.Notification.Style
| |
java.lang.Object
| |
Public constructors
Notification.MediaStyle
Notification.MediaStyle (Notification.Builder builder)
This constructor was deprecated
in API level 24.
use MediaStyle().
| Parameters | |
|---|---|
builder |
Notification.Builder |
Public methods
setMediaSession
Notification.MediaStyle setMediaSession (MediaSession.Token token)
Attach a MediaSession.Token to this Notification
to provide additional playback information and control to the SystemUI.
| Parameters | |
|---|---|
token |
MediaSession.Token |
| Returns | |
|---|---|
Notification.MediaStyle |
|
setShowActionsInCompactView
Notification.MediaStyle setShowActionsInCompactView (int... actions)
Request up to 3 actions (by index in the order of addition) to be shown in the compact notification view.
| Parameters | |
|---|---|
actions |
int: the indices of the actions to show in the compact notification view
|
| Returns | |
|---|---|
Notification.MediaStyle |
|
Interfaces
- ActionBar.OnMenuVisibilityListener
- ActionBar.OnNavigationListener
- ActionBar.TabListener
- AlarmManager.OnAlarmListener
- Application.ActivityLifecycleCallbacks
- Application.OnProvideAssistDataListener
- AppOpsManager.OnOpChangedListener
- DatePickerDialog.OnDateSetListener
- FragmentBreadCrumbs.OnBreadCrumbClickListener
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- KeyguardManager.OnKeyguardExitResult
- LoaderManager.LoaderCallbacks
- Notification.Action.Extender
- Notification.Extender
- PendingIntent.OnFinished
- SearchManager.OnCancelListener
- SearchManager.OnDismissListener
- SharedElementCallback.OnSharedElementsReadyListener
- TimePickerDialog.OnTimeSetListener
- UiAutomation.AccessibilityEventFilter
- UiAutomation.OnAccessibilityEventListener
Classes
- ActionBar
- ActionBar.LayoutParams
- ActionBar.Tab
- Activity
- ActivityGroup
- ActivityManager
- ActivityManager.AppTask
- ActivityManager.MemoryInfo
- ActivityManager.ProcessErrorStateInfo
- ActivityManager.RecentTaskInfo
- ActivityManager.RunningAppProcessInfo
- ActivityManager.RunningServiceInfo
- ActivityManager.RunningTaskInfo
- ActivityManager.TaskDescription
- ActivityOptions
- AlarmManager
- AlarmManager.AlarmClockInfo
- AlertDialog
- AlertDialog.Builder
- AliasActivity
- Application
- ApplicationErrorReport
- ApplicationErrorReport.AnrInfo
- ApplicationErrorReport.BatteryInfo
- ApplicationErrorReport.CrashInfo
- ApplicationErrorReport.RunningServiceInfo
- AppOpsManager
- AutomaticZenRule
- DatePickerDialog
- Dialog
- DialogFragment
- DownloadManager
- DownloadManager.Query
- DownloadManager.Request
- ExpandableListActivity
- Fragment
- Fragment.SavedState
- FragmentBreadCrumbs
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentTransaction
- Instrumentation
- Instrumentation.ActivityMonitor
- Instrumentation.ActivityResult
- IntentService
- KeyguardManager
- KeyguardManager.KeyguardDismissCallback
- KeyguardManager.KeyguardLock
- LauncherActivity
- LauncherActivity.IconResizer
- LauncherActivity.ListItem
- ListActivity
- ListFragment
- LoaderManager
- LocalActivityManager
- MediaRouteActionProvider
- MediaRouteButton
- NativeActivity
- Notification
- Notification.Action
- Notification.Action.Builder
- Notification.Action.WearableExtender
- Notification.BigPictureStyle
- Notification.BigTextStyle
- Notification.Builder
- Notification.CarExtender
- Notification.CarExtender.Builder
- Notification.CarExtender.UnreadConversation
- Notification.DecoratedCustomViewStyle
- Notification.DecoratedMediaCustomViewStyle
- Notification.InboxStyle
- Notification.MediaStyle
- Notification.MessagingStyle
- Notification.MessagingStyle.Message
- Notification.Style
- Notification.WearableExtender
- NotificationChannel
- NotificationChannelGroup
- NotificationManager
- NotificationManager.Policy
- PendingIntent
- PictureInPictureParams
- PictureInPictureParams.Builder
- Presentation
- ProgressDialog
- RemoteAction
- RemoteInput
- RemoteInput.Builder
- SearchableInfo
- SearchManager
- Service
- SharedElementCallback
- TabActivity
- TaskStackBuilder
- TimePickerDialog
- UiAutomation
- UiModeManager
- VoiceInteractor
- VoiceInteractor.AbortVoiceRequest
- VoiceInteractor.CommandRequest
- VoiceInteractor.CompleteVoiceRequest
- VoiceInteractor.ConfirmationRequest
- VoiceInteractor.PickOptionRequest
- VoiceInteractor.PickOptionRequest.Option
- VoiceInteractor.Prompt
- VoiceInteractor.Request
- WallpaperInfo
- WallpaperManager
Exceptions