NotificationCompat.TvExtender
class NotificationCompat.TvExtender : NotificationCompat.Extender
Helper class to add Android TV extensions to notifications.
To create a notification with a TV extension:
- Create an
NotificationCompat.Builder, setting any desired properties. - Create a
TvExtender. - Set TV-specific properties using the
setmethods ofTvExtender. - Call
extendto apply the extension to a notification.
Notification notification = new NotificationCompat.Builder(context) ... .extend(new TvExtender() .setChannelId("channel id")) .build(); NotificationManagerCompat.from(mContext).notify(0, notification);
TV extensions can be accessed on an existing notification by using the TvExtender(Notification) constructor, and then using the get methods to access values.
Note that prior to O this field has no effect.
Summary
Public constructors |
|---|
|
Create a |
TvExtender(notif: Notification)Create a |
Public functions |
|
|---|---|
NotificationCompat.Builder |
extend(builder: NotificationCompat.Builder)Apply a TV extension to a notification that is being built. |
String? |
Returns the id of the channel this notification posts to on TV. |
PendingIntent? |
Returns the TV-specific content intent. |
PendingIntent? |
Returns the TV-specific delete intent. |
Boolean |
Returns true if this notification should be shown on TV. |
Boolean |
Returns true if this notification should not show messages over top of apps outside of the launcher. |
NotificationCompat.TvExtender |
setChannelId(channelId: String?)Specifies the channel the notification should be delivered on when shown on TV. |
NotificationCompat.TvExtender |
setContentIntent(intent: PendingIntent?)Supplies a |
NotificationCompat.TvExtender |
setDeleteIntent(intent: PendingIntent?)Supplies a |
NotificationCompat.TvExtender |
setSuppressShowOverApps(suppress: Boolean)Specifies whether this notification should suppress showing a message over top of apps outside of the launcher. |
Public constructors
TvExtender
TvExtender(notif: Notification)
Create a TvExtender from the TvExtender options of an existing Notification.
| Parameters | |
|---|---|
notif: Notification |
The notification from which to copy options. |
Public functions
extend
fun extend(builder: NotificationCompat.Builder): NotificationCompat.Builder
Apply a TV extension to a notification that is being built. This is typically called by the extend method of NotificationCompat.Builder.
getChannelId
fun getChannelId(): String?
Returns the id of the channel this notification posts to on TV.
getContentIntent
fun getContentIntent(): PendingIntent?
Returns the TV-specific content intent. If this method returns null, the main content intent on the notification should be used.
| See also | |
|---|---|
contentIntent |
getDeleteIntent
fun getDeleteIntent(): PendingIntent?
Returns the TV-specific delete intent. If this method returns null, the main delete intent on the notification should be used.
| See also | |
|---|---|
deleteIntent |
isAvailableOnTv
fun isAvailableOnTv(): Boolean
Returns true if this notification should be shown on TV. This method return true if the notification was extended with a TvExtender.
isSuppressShowOverApps
fun isSuppressShowOverApps(): Boolean
Returns true if this notification should not show messages over top of apps outside of the launcher.
setChannelId
fun setChannelId(channelId: String?): NotificationCompat.TvExtender
Specifies the channel the notification should be delivered on when shown on TV. It can be different from the channel that the notification is delivered to when posting on a non-TV device.
| Parameters | |
|---|---|
channelId: String? |
The channelId to use in the tv notification. |
| Returns | |
|---|---|
NotificationCompat.TvExtender |
The object for method chaining. |
setContentIntent
fun setContentIntent(intent: PendingIntent?): NotificationCompat.TvExtender
Supplies a PendingIntent to be sent when the notification is selected on TV. If provided, it is used instead of the content intent specified at the level of Notification.
setDeleteIntent
fun setDeleteIntent(intent: PendingIntent?): NotificationCompat.TvExtender
Supplies a PendingIntent to send when the notification is cleared explicitly by the user on TV. If provided, it is used instead of the delete intent specified at the level of Notification.
setSuppressShowOverApps
fun setSuppressShowOverApps(suppress: Boolean): NotificationCompat.TvExtender
Specifies whether this notification should suppress showing a message over top of apps outside of the launcher.