Notification.TvExtender


public static final class Notification.TvExtender
extends Object implements Notification.Extender

java.lang.Object
   ↳ android.app.Notification.TvExtender


Helper class to add Android TV extensions to notifications. To create a notification with a TV extension:

  1. Create an Notification.Builder, setting any desired properties.
  2. Create a TvExtender.
  3. Set TV-specific properties using the set methods of TvExtender.
  4. Call Notification.Builder#extend(Notification.Extender) to apply the extension to a notification.
 Notification notification = new Notification.Builder(context)
         ...
         .extend(new TvExtender()
                 .set*(...))
         .build();
 

TV extensions can be accessed on an existing notification by using the TvExtender(Notification) constructor, and then using the get methods to access values.

Summary

Public constructors

TvExtender()

Create a TvExtender with default options.

TvExtender(Notification notif)

Create a TvExtender from the TvExtender options of an existing Notification.

Public methods

Notification.Builder extend(Notification.Builder builder)

Apply a TV extension to a notification that is being built.

String getChannelId()

Returns the id of the channel this notification posts to on TV.

PendingIntent getContentIntent()

Returns the TV-specific content intent.

PendingIntent getDeleteIntent()

Returns the TV-specific delete intent.

boolean isAvailableOnTv()

Returns true if this notification should be shown on TV.

boolean isSuppressShowOverApps()

Returns true if this notification should not show messages over top of apps outside of the launcher.

Notification.TvExtender setChannelId(String channelId)

Specifies the channel the notification should be delivered on when shown on TV.

Notification.TvExtender setContentIntent(PendingIntent intent)

Supplies a PendingIntent to be sent when the notification is selected on TV.

Notification.TvExtender setDeleteIntent(PendingIntent intent)

Supplies a PendingIntent to send when the notification is cleared explicitly by the user on TV.

Notification.TvExtender setSuppressShowOverApps(boolean suppress)

Specifies whether this notification should suppress showing a message over top of apps outside of the launcher.

Inherited methods

Public constructors

TvExtender

public TvExtender ()

Create a TvExtender with default options.

TvExtender

public TvExtender (Notification notif)

Create a TvExtender from the TvExtender options of an existing Notification.

Parameters
notif Notification: The notification from which to copy options. This value cannot be null.

Public methods

extend

public Notification.Builder extend (Notification.Builder builder)

Apply a TV extension to a notification that is being built. This is typically called by the Notification.Builder#extend(Notification.Extender) method of Notification.Builder.

Parameters
builder Notification.Builder: This value cannot be null.

Returns
Notification.Builder This value cannot be null.

getChannelId

public String getChannelId ()

Returns the id of the channel this notification posts to on TV.

Returns
String This value may be null.

getContentIntent

public PendingIntent getContentIntent ()

Returns the TV-specific content intent. If this method returns null, the main content intent on the notification should be used.

Returns
PendingIntent

getDeleteIntent

public PendingIntent getDeleteIntent ()

Returns the TV-specific delete intent. If this method returns null, the main delete intent on the notification should be used.

Returns
PendingIntent

isAvailableOnTv

public boolean isAvailableOnTv ()

Returns true if this notification should be shown on TV. This method returns true if the notification was extended with a TvExtender.

Returns
boolean

isSuppressShowOverApps

public boolean isSuppressShowOverApps ()

Returns true if this notification should not show messages over top of apps outside of the launcher.

Returns
boolean

setChannelId

public Notification.TvExtender setChannelId (String channelId)

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: This value may be null.

Returns
Notification.TvExtender this object for method chaining This value cannot be null.

setContentIntent

public Notification.TvExtender setContentIntent (PendingIntent intent)

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.

Parameters
intent PendingIntent: the PendingIntent for the associated notification content This value may be null.

Returns
Notification.TvExtender this object for method chaining This value cannot be null.

setDeleteIntent

public Notification.TvExtender setDeleteIntent (PendingIntent intent)

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.

Parameters
intent PendingIntent: the PendingIntent for the associated notification deletion This value may be null.

Returns
Notification.TvExtender this object for method chaining This value cannot be null.

setSuppressShowOverApps

public Notification.TvExtender setSuppressShowOverApps (boolean suppress)

Specifies whether this notification should suppress showing a message over top of apps outside of the launcher.

Parameters
suppress boolean: whether the notification should suppress showing over apps.

Returns
Notification.TvExtender this object for method chaining This value cannot be null.