# NotificationCompat.TvExtender

# NotificationCompat.TvExtender

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.TvExtender)  
Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/app/NotificationCompat.TvExtender "View this page in Java")

<br />

```
class NotificationCompat.TvExtender : NotificationCompat.Extender
```

<br />

*** ** * ** ***

Helper class to add Android TV extensions to notifications.

To create a notification with a TV extension:

1. Create an[NotificationCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder), setting any desired properties.
2. Create a[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender).
3. Set TV-specific properties using the`set`methods of[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender).
4. Call[extend](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#extend(androidx.core.app.NotificationCompat.Extender))to apply the extension to a notification.

```kotlin
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](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#O())this field has no effect.

## Summary

|                                                                                                                                                                                                     ### Public constructors                                                                                                                                                                                                      |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#TvExtender())`()` Create a[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender)with default options.                                                                                                                                                          |
| [TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#TvExtender(android.app.Notification))`(notif: `[Notification](https://developer.android.com/reference/android/app/Notification.html)`)` Create a[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender)from the TvExtender options of an existing Notification. |

|                                                      ### Public functions                                                       |
|---------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [NotificationCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder)       | [extend](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#extend(androidx.core.app.NotificationCompat.Builder))`(builder: `[NotificationCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder)`)` Apply a TV extension to a notification that is being built.                                                                          |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                            | [getChannelId](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#getChannelId())`()` Returns the id of the channel this notification posts to on TV.                                                                                                                                                                                                                                          |
| [PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)`?`                                      | [getContentIntent](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#getContentIntent())`()` Returns the TV-specific content intent.                                                                                                                                                                                                                                                          |
| [PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)`?`                                      | [getDeleteIntent](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#getDeleteIntent())`()` Returns the TV-specific delete intent.                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                             | [isAvailableOnTv](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#isAvailableOnTv())`()` Returns true if this notification should be shown on TV.                                                                                                                                                                                                                                           |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                             | [isSuppressShowOverApps](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#isSuppressShowOverApps())`()` Returns true if this notification should not show messages over top of apps outside of the launcher.                                                                                                                                                                                 |
| [NotificationCompat.TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender) | [setChannelId](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#setChannelId(java.lang.String))`(channelId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Specifies the channel the notification should be delivered on when shown on TV.                                                                                                           |
| [NotificationCompat.TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender) | [setContentIntent](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#setContentIntent(android.app.PendingIntent))`(intent: `[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)`?)` Supplies a[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)to be sent when the notification is selected on TV.                  |
| [NotificationCompat.TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender) | [setDeleteIntent](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#setDeleteIntent(android.app.PendingIntent))`(intent: `[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)`?)` Supplies a[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)to send when the notification is cleared explicitly by the user on TV. |
| [NotificationCompat.TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender) | [setSuppressShowOverApps](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender#setSuppressShowOverApps(boolean))`(suppress: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Specifies whether this notification should suppress showing a message over top of apps outside of the launcher.                                                              |

## Public constructors

### TvExtender

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
TvExtender()
```

Create a[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender)with default options.  

### TvExtender

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
TvExtender(notif: Notification)
```

Create a[TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender)from the TvExtender options of an existing Notification.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|----------------------------------------------|
| `notif: `[Notification](https://developer.android.com/reference/android/app/Notification.html) | 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](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#extend(androidx.core.app.NotificationCompat.Extender))method of[NotificationCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder).  

### getChannelId

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun getChannelId(): String?
```

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

### getContentIntent

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
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](https://developer.android.com/reference/android/app/Notification.html#contentIntent()) | [contentIntent](https://developer.android.com/reference/android/app/Notification.html#contentIntent()) |

### getDeleteIntent

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
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](https://developer.android.com/reference/android/app/Notification.html#deleteIntent()) | [deleteIntent](https://developer.android.com/reference/android/app/Notification.html#deleteIntent()) |

### isAvailableOnTv

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
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

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun isSuppressShowOverApps(): Boolean
```

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

### setChannelId

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | The channelId to use in the tv notification. |

|                                                             Returns                                                             |
|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.TvExtender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.TvExtender) | The object for method chaining. |

### setContentIntent

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setContentIntent(intent: PendingIntent?): NotificationCompat.TvExtender
```

Supplies a[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)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

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setDeleteIntent(intent: PendingIntent?): NotificationCompat.TvExtender
```

Supplies a[PendingIntent](https://developer.android.com/reference/android/app/PendingIntent.html)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

Added in[1.11.0](https://developer.android.com/jetpack/androidx/releases/core#1.11.0)  

```
fun setSuppressShowOverApps(suppress: Boolean): NotificationCompat.TvExtender
```

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