public final class

NotificationCompat.TvExtender

extends java.lang.Object

implements NotificationCompat.Extender

 java.lang.Object

↳androidx.core.app.NotificationCompat.TvExtender

Overview

Helper class to add Android TV extensions to notifications.

To create a notification with a TV extension:

  1. Create an NotificationCompat.Builder, setting any desired properties.
  2. Create a NotificationCompat.TvExtender.
  3. Set TV-specific properties using the set methods of NotificationCompat.TvExtender.
  4. Call NotificationCompat.Builder.extend(NotificationCompat.Extender) to 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 this field has no effect.

Summary

Constructors
publicTvExtender()

Create a NotificationCompat.TvExtender with default options.

publicTvExtender(Notification notif)

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

Methods
public NotificationCompat.Builderextend(NotificationCompat.Builder builder)

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

public java.lang.StringgetChannelId()

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

public PendingIntentgetContentIntent()

Returns the TV-specific content intent.

public PendingIntentgetDeleteIntent()

Returns the TV-specific delete intent.

public booleanisAvailableOnTv()

Returns true if this notification should be shown on TV.

public booleanisSuppressShowOverApps()

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

public NotificationCompat.TvExtendersetChannelId(java.lang.String channelId)

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

public NotificationCompat.TvExtendersetContentIntent(PendingIntent intent)

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

public NotificationCompat.TvExtendersetDeleteIntent(PendingIntent intent)

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

public NotificationCompat.TvExtendersetSuppressShowOverApps(boolean suppress)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public TvExtender()

Create a NotificationCompat.TvExtender with default options.

public TvExtender(Notification notif)

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

Parameters:

notif: The notification from which to copy options.

Methods

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

public boolean isAvailableOnTv()

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

public NotificationCompat.TvExtender setChannelId(java.lang.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: The channelId to use in the tv notification.

Returns:

The object for method chaining.

public java.lang.String getChannelId()

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

public NotificationCompat.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.

public PendingIntent getContentIntent()

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

See also:

public NotificationCompat.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.

public PendingIntent getDeleteIntent()

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

See also:

public NotificationCompat.TvExtender setSuppressShowOverApps(boolean suppress)

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

public boolean isSuppressShowOverApps()

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