Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/media/tv/TvInputService.Session#pubctors) \| [Methods](https://developer.android.com/reference/android/media/tv/TvInputService.Session#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/tv/TvInputService.Session#inhmethods)

# TvInputService.Session

*** ** * ** ***

` public static abstract class TvInputService.Session `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/android/view/KeyEvent.Callback `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.tv.TvInputService.Session |

Known direct subclasses [TvInputService.HardwareSession](https://developer.android.com/reference/android/media/tv/TvInputService.HardwareSession) [TvInputService.HardwareSession](https://developer.android.com/reference/android/media/tv/TvInputService.HardwareSession) Base class for a TV input session which represents an external device connected to a hardware TV input.   

*** ** * ** ***

Base class for derived classes to implement to provide a TV input session.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#Session(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Creates a new Session. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#layoutSurface(int,%20int,%20int,%20int)(int left, int top, int right, int bottom) ` Assigns a size and position to the surface passed in `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)`. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAdBufferConsumed(android.media.tv.AdBuffer)(https://developer.android.com/reference/android/media/tv/AdBuffer buffer) ` Notifies the advertisement buffer is consumed. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAdResponse(android.media.tv.AdResponse)(https://developer.android.com/reference/android/media/tv/AdResponse response) ` Notifies response for advertisement. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAitInfoUpdated(android.media.tv.AitInfo)(https://developer.android.com/reference/android/media/tv/AitInfo aitInfo) ` Informs the app that the AIT (Application Information Table) is updated. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAudioPresentationChanged(java.util.List<android.media.AudioPresentation>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/media/AudioPresentation> audioPresentations) ` Sends an updated list of all audio presentations available from a Next Generation Audio service. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(int,%20int)(int presentationId, int programId) ` Sends the presentation and program IDs of the selected audio presentation. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAvailableSpeeds(float[])(float[] speeds) ` Informs the app available speeds for time-shifting. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyBroadcastInfoResponse(android.media.tv.BroadcastInfoResponse)(https://developer.android.com/reference/android/media/tv/BroadcastInfoResponse response) ` Notifies response for broadcast info. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyChannelRetuned(android.net.Uri)(https://developer.android.com/reference/android/net/Uri channelUri) ` Informs the application that the current channel is re-tuned for some reason and the session now displays the content from a new channel. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyContentAllowed()() ` Informs the application that the user is allowed to watch the current program content. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyContentBlocked(android.media.tv.TvContentRating)(https://developer.android.com/reference/android/media/tv/TvContentRating rating) ` Informs the application that the current program content is blocked by parent controls. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyCueingMessageAvailability(boolean)(boolean available) ` Informs the application that cueing message is available or unavailable. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifySignalStrength(int)(int strength) ` Notifies signal strength. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTimeShiftMode(int)(int mode) ` Informs the app that the time shift mode is set or updated. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTimeShiftStatusChanged(int)(int status) ` Informs the application that the time shift status is changed. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTrackSelected(int,%20java.lang.String)(int type, https://developer.android.com/reference/java/lang/String trackId) ` Sends the type and ID of a selected track. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTracksChanged(java.util.List<android.media.tv.TvTrackInfo>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/media/tv/TvTrackInfo> tracks) ` Sends the list of all audio/video/subtitle tracks. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTuned(android.net.Uri)(https://developer.android.com/reference/android/net/Uri channelUri) ` Informs the application that this session has been tuned to the given channel. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTvMessage(int,%20android.os.Bundle)(int type, https://developer.android.com/reference/android/os/Bundle data) ` Sends the raw data from the received TV message as well as the type of message received. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoAvailable()() ` Informs the application that the video is now available for watching. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoFreezeUpdated(boolean)(boolean isFrozen) ` Informs the application that the video freeze state has been updated. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoUnavailable(int)(int reason) ` Informs the application that the video became unavailable for some reason. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onAdBufferReady(android.media.tv.AdBuffer)(https://developer.android.com/reference/android/media/tv/AdBuffer buffer) ` Called when an advertisement buffer is ready for playback. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onAppPrivateCommand(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String action, https://developer.android.com/reference/android/os/Bundle data) ` Processes a private command sent from the application to the TV input. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onCreateOverlayView()() ` Called when the application requests to create an overlay view. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onGenericMotionEvent(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) ` Implement this method to handle generic motion events on the current input session. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onKeyDown(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyDown(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event). |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onKeyLongPress(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event). |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onKeyMultiple(int,%20int,%20android.view.KeyEvent)(int keyCode, int count, https://developer.android.com/reference/android/view/KeyEvent event) ` Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event). |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onKeyUp(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyUp(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event). |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(int,%20int)(int width, int height) ` Called when the size of the overlay view is changed by the application. |
| ` abstract void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onRelease()() ` Called when the session is released. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onRemoveBroadcastInfo(int)(int requestId) ` Called when broadcast info is removed. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onRequestAd(android.media.tv.AdRequest)(https://developer.android.com/reference/android/media/tv/AdRequest request) ` Called when advertisement request is received. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onRequestBroadcastInfo(android.media.tv.BroadcastInfoRequest)(https://developer.android.com/reference/android/media/tv/BroadcastInfoRequest request) ` Called when broadcast info is requested. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onResumePlayback()() ` Resumes playback of the Audio, Video, and CC streams. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectAudioPresentation(int,%20int)(int presentationId, int programId) ` Selects an audio presentation. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectTrack(int,%20java.lang.String)(int type, https://developer.android.com/reference/java/lang/String trackId) ` Selects a given track. |
| ` abstract void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetCaptionEnabled(boolean)(boolean enabled) ` Enables or disables the caption. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(boolean)(boolean enabled) ` Enables or disables interactive app notification. |
| ` abstract void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetStreamVolume(float)(float volume) ` Sets the relative stream volume of the current TV input session. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)(https://developer.android.com/reference/android/view/Surface surface) ` Called when the application sets the surface. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetTvMessageEnabled(int,%20boolean)(int type, boolean enabled) ` Called when the application enables or disables the detection of the specified message type. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onStopPlayback(int)(int mode) ` Called when the application requests playback of the Audio, Video, and CC streams to be stopped, but the metadata should continue to be filtered. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSurfaceChanged(int,%20int,%20int)(int format, int width, int height) ` Called after any structural changes (format or size) have been made to the surface passed in `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)`. |
| ` long` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()() ` Returns the current position for time shifting, in milliseconds since the epoch. |
| ` long` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()() ` Returns the start position for time shifting, in milliseconds since the epoch. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()() ` Called when the application requests to pause playback. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)(https://developer.android.com/reference/android/net/Uri recordedProgramUri) ` Called when the application requests to play a given recorded TV program. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()() ` Called when the application requests to resume playback. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)(long timeMs) ` Called when the application requests to seek to a specified time position. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetMode(int)(int mode) ` Called when the application sets time shift mode. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)(https://developer.android.com/reference/android/media/PlaybackParams params) ` Called when the application sets playback parameters containing the speed and audio mode. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTouchEvent(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) ` Implement this method to handle touch screen motion events on the current input session. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTrackballEvent(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) ` Implement this method to handle trackball events on the current input session. |
| ` boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTune(android.net.Uri,%20android.os.Bundle)(https://developer.android.com/reference/android/net/Uri channelUri, https://developer.android.com/reference/android/os/Bundle params) ` Tunes to a given channel. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTune(android.net.Uri)(https://developer.android.com/reference/android/net/Uri channelUri) ` Tunes to a given channel. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTvAdSessionData(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/android/os/Bundle data) ` Called when data from the linked `https://developer.android.com/reference/android/media/tv/ad/TvAdService` is received. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTvMessage(int,%20android.os.Bundle)(int type, https://developer.android.com/reference/android/os/Bundle data) ` Called when a TV message is received |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#onUnblockContent(android.media.tv.TvContentRating)(https://developer.android.com/reference/android/media/tv/TvContentRating unblockedRating) ` Requests to unblock the content according to the given rating. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#sendTvInputSessionData(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String type, https://developer.android.com/reference/android/os/Bundle data) ` Sends data related to this session to corresponding linked `https://developer.android.com/reference/android/media/tv/ad/TvAdService` object via TvAdView. |
| ` void` | ` https://developer.android.com/reference/android/media/tv/TvInputService.Session#setOverlayViewEnabled(boolean)(boolean enable) ` Enables or disables the overlay view. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/view/KeyEvent.Callback ` ` abstract boolean` ` https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyDown(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) `

Called when a key down event has occurred.
` abstract boolean` ` https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) `

Called when a long press has occurred.
` abstract boolean` ` https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)(int keyCode, int count, https://developer.android.com/reference/android/view/KeyEvent event) `

Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession.
` abstract boolean` ` https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyUp(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) `

Called when a key up event has occurred.

## Public constructors

### Session

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Session (Context context)
```

Creates a new Session.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The context of the application <br /> |

## Public methods

### layoutSurface

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void layoutSurface (int left, 
                int top, 
                int right, 
                int bottom)
```

Assigns a size and position to the surface passed in `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)`. The position is relative to the overlay view that sits on top of this surface.

<br />

| Parameters ||
|---|---|
| `left` | `int`: Left position in pixels, relative to the overlay view. <br /> |
| `top` | `int`: Top position in pixels, relative to the overlay view. <br /> |
| `right` | `int`: Right position in pixels, relative to the overlay view. <br /> |
| `bottom` | `int`: Bottom position in pixels, relative to the overlay view. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(int,%20int)`

### notifyAdBufferConsumed

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAdBufferConsumed (AdBuffer buffer)
```

Notifies the advertisement buffer is consumed.

<br />

| Parameters ||
|---|---|
| `buffer` | `AdBuffer`: the `https://developer.android.com/reference/android/media/tv/AdBuffer` that was consumed. This value cannot be `null`. <br /> |

### notifyAdResponse

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAdResponse (AdResponse response)
```

Notifies response for advertisement.

<br />

| Parameters ||
|---|---|
| `response` | `AdResponse`: advertisement response. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/interactive/TvInteractiveAppService.Session#requestAd(android.media.tv.AdRequest)`

### notifyAitInfoUpdated

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAitInfoUpdated (AitInfo aitInfo)
```

Informs the app that the AIT (Application Information Table) is updated.

This method should also be called when `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(boolean)` is called to send the first AIT info.

<br />

| Parameters ||
|---|---|
| `aitInfo` | `AitInfo`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetInteractiveAppNotificationEnabled(boolean)`

### notifyAudioPresentationChanged

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAudioPresentationChanged (List<AudioPresentation> audioPresentations)
```

Sends an updated list of all audio presentations available from a Next Generation Audio service. This is used by the framework to maintain the audio presentation information for a given track of `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_AUDIO`, which in turn is used by `https://developer.android.com/reference/android/media/tv/TvView#getAudioPresentations()` for the application to retrieve metadata for the current audio track. The TV input service must call this method as soon as the audio track presentation information becomes available or is updated. Note that in a case where a part of the information for the current track is updated, it is not necessary to create a new `https://developer.android.com/reference/android/media/tv/TvTrackInfo` object with a different track ID.

<br />

| Parameters ||
|---|---|
| `audioPresentations` | `List`: A list of audio presentation information pertaining to the selected track. This value cannot be `null`. <br /> |

### notifyAudioPresentationSelected

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAudioPresentationSelected (int presentationId, 
                int programId)
```

Sends the presentation and program IDs of the selected audio presentation. This is used to inform the application that a specific audio presentation is selected. The TV input service must call this method as soon as an audio presentation is selected either by default or in response to a call to `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectTrack(int,%20java.lang.String)`. The selected audio presentation ID for a currently selected audio track is maintained in the framework until the next call to this method even after the entire audio presentation list for the track is updated (but is reset when the session is tuned to a new channel), so care must be taken not to result in an obsolete track audio presentation ID.

<br />

| Parameters ||
|---|---|
| `presentationId` | `int`: The ID of the selected audio presentation for the current track. <br /> |
| `programId` | `int`: The ID of the program providing the selected audio presentation. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectAudioPresentation(int,%20int)`

### notifyAvailableSpeeds

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyAvailableSpeeds (float[] speeds)
```

Informs the app available speeds for time-shifting.

This should be called when time-shifting is enabled.

<br />

| Parameters ||
|---|---|
| `speeds` | `float`: An ordered array of playback speeds, expressed as values relative to the normal playback speed (1.0), at which the current content can be played as a time-shifted broadcast. This is an empty array if the supported playback speeds are unknown or the video/broadcast is not in time shift mode. If currently in time shift mode, this array will normally include at least the values 1.0 (normal speed) and 0.0 (paused). This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/PlaybackParams#getSpeed()`

### notifyBroadcastInfoResponse

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyBroadcastInfoResponse (BroadcastInfoResponse response)
```

Notifies response for broadcast info.

<br />

| Parameters ||
|---|---|
| `response` | `BroadcastInfoResponse`: broadcast info response. This value cannot be `null`. <br /> |

### notifyChannelRetuned

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyChannelRetuned (Uri channelUri)
```

Informs the application that the current channel is re-tuned for some reason and the session now displays the content from a new channel. This is used to handle special cases such as when the current channel becomes unavailable, it is necessary to send the user to a certain channel or the user changes channel in some other way (e.g. by using a dedicated remote).

<br />

| Parameters ||
|---|---|
| `channelUri` | `Uri`: The URI of the new channel. <br /> |

### notifyContentAllowed

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyContentAllowed ()
```

Informs the application that the user is allowed to watch the current program content.

Each TV input service is required to query the system whether the user is allowed to watch the current program before showing it to the user if the parental controls is enabled (i.e. `https://developer.android.com/reference/android/media/tv/TvInputManager#isParentalControlsEnabled()` returns `true`). Whether the TV input service should block the content or not is determined by invoking `https://developer.android.com/reference/android/media/tv/TvInputManager#isRatingBlocked(android.media.tv.TvContentRating)` with the content rating for the current program. Then the `https://developer.android.com/reference/android/media/tv/TvInputManager` makes a judgment based on the user blocked ratings stored in the secure settings and returns the result. If the rating in question turns out to be allowed by the user, the TV input service must call this method to notify the application that is permitted to show the content.

Each TV input service also needs to continuously listen to any changes made to the parental controls settings by registering a broadcast receiver to receive `https://developer.android.com/reference/android/media/tv/TvInputManager#ACTION_BLOCKED_RATINGS_CHANGED` and `https://developer.android.com/reference/android/media/tv/TvInputManager#ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED` and immediately reevaluate the current program with the new parental controls settings.

<br />

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyContentBlocked(android.media.tv.TvContentRating)`
- `https://developer.android.com/reference/android/media/tv/TvInputManager`

### notifyContentBlocked

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyContentBlocked (TvContentRating rating)
```

Informs the application that the current program content is blocked by parent controls.

Each TV input service is required to query the system whether the user is allowed to watch the current program before showing it to the user if the parental controls is enabled (i.e. `https://developer.android.com/reference/android/media/tv/TvInputManager#isParentalControlsEnabled()` returns `true`). Whether the TV input service should block the content or not is determined by invoking `https://developer.android.com/reference/android/media/tv/TvInputManager#isRatingBlocked(android.media.tv.TvContentRating)` with the content rating for the current program or `https://developer.android.com/reference/android/media/tv/TvContentRating#UNRATED` in case the rating information is missing. Then the `https://developer.android.com/reference/android/media/tv/TvInputManager` makes a judgment based on the user blocked ratings stored in the secure settings and returns the result. If the rating in question turns out to be blocked, the TV input service must immediately block the content and call this method with the content rating of the current program to prompt the PIN verification screen.

Each TV input service also needs to continuously listen to any changes made to the parental controls settings by registering a broadcast receiver to receive `https://developer.android.com/reference/android/media/tv/TvInputManager#ACTION_BLOCKED_RATINGS_CHANGED` and `https://developer.android.com/reference/android/media/tv/TvInputManager#ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED` and immediately reevaluate the current program with the new parental controls settings.

<br />

| Parameters ||
|---|---|
| `rating` | `TvContentRating`: The content rating for the current TV program. Can be `https://developer.android.com/reference/android/media/tv/TvContentRating#UNRATED`. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyContentAllowed()`
- `https://developer.android.com/reference/android/media/tv/TvInputManager`

### notifyCueingMessageAvailability

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyCueingMessageAvailability (boolean available)
```

Informs the application that cueing message is available or unavailable.

The cueing message is used for digital program insertion, based on the standard ANSI/SCTE 35 2019r1.

<br />

| Parameters ||
|---|---|
| `available` | `boolean`: `true` if cueing message is available; `false` if it becomes unavailable. <br /> |

### notifySignalStrength

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifySignalStrength (int strength)
```

Notifies signal strength.

<br />

| Parameters ||
|---|---|
| `strength` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#SIGNAL_STRENGTH_LOST` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SIGNAL_STRENGTH_WEAK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SIGNAL_STRENGTH_STRONG` |

### notifyTimeShiftMode

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTimeShiftMode (int mode)
```

Informs the app that the time shift mode is set or updated.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: The current time shift mode. The value is one of the following: `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO`. Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO` |

### notifyTimeShiftStatusChanged

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTimeShiftStatusChanged (int status)
```

Informs the application that the time shift status is changed.

Prior to calling this method, the application assumes the status `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNKNOWN`. Right after the session is created, it is important to invoke the method with the status `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE` if the implementation does support time shifting, or `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED` otherwise. Failure to notifying the current status change immediately might result in an undesirable behavior in the application such as hiding the play controls.

If the status `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE` is reported, the application assumes it can pause/resume playback, seek to a specified time position and set playback rate and audio mode. The implementation should override `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()` and `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`.

<br />

| Parameters ||
|---|---|
| `status` | `int`: The current time shift status. Should be one of the followings. - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNAVAILABLE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE` . Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNKNOWN` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNSUPPORTED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_UNAVAILABLE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_STATUS_AVAILABLE` |

### notifyTrackSelected

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTrackSelected (int type, 
                String trackId)
```

Sends the type and ID of a selected track. This is used to inform the application that a specific track is selected. The TV input service must call this method as soon as a track is selected either by default or in response to a call to `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectTrack(int,%20java.lang.String)`. The selected track ID for a given type is maintained in the framework until the next call to this method even after the entire track list is updated (but is reset when the session is tuned to a new channel), so care must be taken not to result in an obsolete track ID.

<br />

| Parameters ||
|---|---|
| `type` | `int`: The type of the selected track. The type can be `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_AUDIO`, `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_VIDEO` or `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_SUBTITLE`. <br /> |
| `trackId` | `String`: The ID of the selected track. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSelectTrack(int,%20java.lang.String)`

### notifyTracksChanged

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTracksChanged (List<TvTrackInfo> tracks)
```

Sends the list of all audio/video/subtitle tracks. The is used by the framework to maintain the track information for a given session, which in turn is used by `https://developer.android.com/reference/android/media/tv/TvView#getTracks(int)` for the application to retrieve metadata for a given track type. The TV input service must call this method as soon as the track information becomes available or is updated. Note that in a case where a part of the information for a certain track is updated, it is not necessary to create a new `https://developer.android.com/reference/android/media/tv/TvTrackInfo` object with a different track ID.

<br />

| Parameters ||
|---|---|
| `tracks` | `List`: A list which includes track information. <br /> |

### notifyTuned

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTuned (Uri channelUri)
```

Informs the application that this session has been tuned to the given channel.

<br />

| Parameters ||
|---|---|
| `channelUri` | `Uri`: The URI of the tuned channel. This value cannot be `null`. <br /> |

### notifyTvMessage

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyTvMessage (int type, 
                Bundle data)
```

Sends the raw data from the received TV message as well as the type of message received.

<br />

| Parameters ||
|---|---|
| `type` | `int`: The of message that was sent, such as `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER` |
| `data` | `Bundle`: The raw data of the message. The bundle keys are: `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_STREAM_ID`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_GROUP_ID`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_RAW_DATA`. See `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE` for more information on how to parse this data. This value cannot be `null`. <br /> |

### notifyVideoAvailable

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyVideoAvailable ()
```

Informs the application that the video is now available for watching. Video is blocked until this method is called.

The TV input service must call this method as soon as the content rendered onto its surface is ready for viewing. This method must be called each time `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTune(android.net.Uri)` is called.

<br />

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoUnavailable(int)`

### notifyVideoFreezeUpdated

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyVideoFreezeUpdated (boolean isFrozen)
```

Informs the application that the video freeze state has been updated.

When `true`, the video is frozen on the last frame but audio playback remains active.

<br />

| Parameters ||
|---|---|
| `isFrozen` | `boolean`: Whether or not the video is frozen <br /> |

### notifyVideoUnavailable

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void notifyVideoUnavailable (int reason)
```

Informs the application that the video became unavailable for some reason. This is primarily used to signal the application to block the screen not to show any intermittent video artifacts.

<br />

| Parameters ||
|---|---|
| `reason` | `int`: The reason why the video became unavailable: - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY` . Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_NOT_CONNECTED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_INSUFFICIENT_RESOURCE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_INSUFFICIENT_OUTPUT_PROTECTION` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_PVR_RECORDING_NOT_ALLOWED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_LICENSE_EXPIRED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_ACTIVATION` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_PAIRING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NO_CARD` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_MUTE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_INVALID` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_BLACKOUT` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_REBOOTING` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_UNKNOWN` - `https://developer.android.com/reference/android/media/tv/TvInputManager#VIDEO_UNAVAILABLE_REASON_STOPPED` |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoAvailable()`

### onAdBufferReady

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onAdBufferReady (AdBuffer buffer)
```

Called when an advertisement buffer is ready for playback.

<br />

| Parameters ||
|---|---|
| `buffer` | `AdBuffer`: The `https://developer.android.com/reference/android/media/tv/AdBuffer` that became ready for playback. This value cannot be `null`. <br /> |

### onAppPrivateCommand

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onAppPrivateCommand (String action, 
                Bundle data)
```

Processes a private command sent from the application to the TV input. This can be used to provide domain-specific features that are only known between certain TV inputs and their clients.

<br />

| Parameters ||
|---|---|
| `action` | `String`: Name of the command to be performed. This *must* be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting commands. This value cannot be `null`. <br /> |
| `data` | `Bundle`: Any data to include with the command. <br /> |

### onCreateOverlayView

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View onCreateOverlayView ()
```

Called when the application requests to create an overlay view. Each session implementation can override this method and return its own view.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | a view attached to the overlay window <br /> |

### onGenericMotionEvent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onGenericMotionEvent (MotionEvent event)
```

Implement this method to handle generic motion events on the current input session.

<br />

| Parameters ||
|---|---|
| `event` | `MotionEvent`: The motion event being received. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onGenericMotionEvent(android.view.MotionEvent)`

### onKeyDown

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyDown (int keyCode, 
                KeyEvent event)
```

Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyDown(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event).

Override this to intercept key down events before they are processed by the application. If you return true, the application will not process the event itself. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event` | `KeyEvent`: Description of the key event. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

### onKeyLongPress

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyLongPress (int keyCode, 
                KeyEvent event)
```

Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyLongPress(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event).

Override this to intercept key long press events before they are processed by the application. If you return true, the application will not process the event itself. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event` | `KeyEvent`: Description of the key event. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

### onKeyMultiple

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyMultiple (int keyCode, 
                int count, 
                KeyEvent event)
```

Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyMultiple(int,%20int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event).

Override this to intercept special key multiple events before they are processed by the application. If you return true, the application will not itself process the event. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `count` | `int`: The number of times the action was made. <br /> |
| `event` | `KeyEvent`: Description of the key event. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

### onKeyUp

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyUp (int keyCode, 
                KeyEvent event)
```

Default implementation of `https://developer.android.com/reference/android/view/KeyEvent.Callback#onKeyUp(int,%20android.view.KeyEvent)`: always returns false (doesn't handle the event).

Override this to intercept key up events before they are processed by the application. If you return true, the application will not itself process the event. If you return false, the normal application processing will occur as if the TV input had not seen the event at all.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: The value in event.getKeyCode(). <br /> |
| `event` | `KeyEvent`: Description of the key event. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

### onOverlayViewSizeChanged

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onOverlayViewSizeChanged (int width, 
                int height)
```

Called when the size of the overlay view is changed by the application.

This is always called at least once when the session is created regardless of whether the overlay view is enabled or not. The overlay view size is the same as the containing `https://developer.android.com/reference/android/media/tv/TvView`. Note that the size of the underlying surface can be different if the surface was changed by calling `https://developer.android.com/reference/android/media/tv/TvInputService.Session#layoutSurface(int,%20int,%20int,%20int)`.

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width of the overlay view. <br /> |
| `height` | `int`: The height of the overlay view. <br /> |

### onRelease

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onRelease ()
```

Called when the session is released.

<br />

### onRemoveBroadcastInfo

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onRemoveBroadcastInfo (int requestId)
```

Called when broadcast info is removed.

<br />

| Parameters ||
|---|---|
| `requestId` | `int` <br /> |

### onRequestAd

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onRequestAd (AdRequest request)
```

Called when advertisement request is received.

<br />

| Parameters ||
|---|---|
| `request` | `AdRequest`: advertisement request received. This value cannot be `null`. <br /> |

### onRequestBroadcastInfo

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onRequestBroadcastInfo (BroadcastInfoRequest request)
```

Called when broadcast info is requested.

<br />

| Parameters ||
|---|---|
| `request` | `BroadcastInfoRequest`: broadcast info request. This value cannot be `null`. <br /> |

### onResumePlayback

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onResumePlayback ()
```

Resumes playback of the Audio, Video, and CC streams.

Note that this is different form `https://developer.android.com/` as this is intended to be used after stopping playback. This is used to resume playback from the current position in the live broadcast.

<br />

### onSelectAudioPresentation

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onSelectAudioPresentation (int presentationId, 
                int programId)
```

Selects an audio presentation.

On successfully selecting the audio presentation, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(int,%20int)` is invoked to provide updated information about the selected audio presentation to applications.

<br />

| Parameters ||
|---|---|
| `presentationId` | `int`: The ID of the audio presentation to select. <br /> |
| `programId` | `int`: The ID of the program providing the selected audio presentation. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the audio presentation selection was successful, `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAudioPresentationSelected(int,%20int)`

### onSelectTrack

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onSelectTrack (int type, 
                String trackId)
```

Selects a given track.

If this is done successfully, the implementation should call `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTrackSelected(int,%20java.lang.String)` to help applications maintain the up-to-date list of the selected tracks.

<br />

| Parameters ||
|---|---|
| `type` | `int`: The type of the track to select. The type can be `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_AUDIO`, `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_VIDEO` or `https://developer.android.com/reference/android/media/tv/TvTrackInfo#TYPE_SUBTITLE`. <br /> |
| `trackId` | `String`: The ID of the track to select. `null` means to unselect the current track for a given type. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the track selection was successful, `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyTrackSelected(int,%20java.lang.String)`

### onSetCaptionEnabled

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onSetCaptionEnabled (boolean enabled)
```

Enables or disables the caption.

The locale for the user's preferred captioning language can be obtained by calling `https://developer.android.com/reference/android/view/accessibility/CaptioningManager#getLocale()`.

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean`: `true` to enable, `false` to disable. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/accessibility/CaptioningManager`

### onSetInteractiveAppNotificationEnabled

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSetInteractiveAppNotificationEnabled (boolean enabled)
```

Enables or disables interactive app notification.

This method enables or disables the event detection from the corresponding TV input. When it's enabled, the TV input service detects events related to interactive app, such as AIT (Application Information Table) and sends to TvView or the linked TV interactive app service.

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean`: `true` to enable, `false` to disable. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvView#setInteractiveAppNotificationEnabled(boolean)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyAitInfoUpdated(android.media.tv.AitInfo)`

### onSetStreamVolume

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onSetStreamVolume (float volume)
```

Sets the relative stream volume of the current TV input session.

The implementation should honor this request in order to handle audio focus changes or mute the current session when multiple sessions, possibly from different inputs are active. If the method has not yet been called, the implementation should assume the default value of `1.0f`.

<br />

| Parameters ||
|---|---|
| `volume` | `float`: A volume value between `0.0f` to `1.0f`. Value is between 0.0f and 1.0f inclusive <br /> |

### onSetSurface

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean onSetSurface (Surface surface)
```

Called when the application sets the surface.

The TV input service should render video onto the given surface. When called with `null`, the input service should immediately free any references to the currently set surface and stop using it.

<br />

| Parameters ||
|---|---|
| `surface` | `Surface`: The surface to be used for video rendering. Can be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the surface was set successfully, `false` otherwise. <br /> |

### onSetTvMessageEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSetTvMessageEnabled (int type, 
                boolean enabled)
```

Called when the application enables or disables the detection of the specified message type.

<br />

| Parameters ||
|---|---|
| `type` | `int`: The type of message received, such as `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER` |
| `enabled` | `boolean`: `true` if TV message detection is enabled, `false` otherwise. <br /> |

### onStopPlayback

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onStopPlayback (int mode)
```

Called when the application requests playback of the Audio, Video, and CC streams to be stopped, but the metadata should continue to be filtered.

The metadata that will continue to be filtered includes the PSI (Program specific information) and SI (Service Information), part of ISO/IEC 13818-1.

Note that this is different form `https://developer.android.com/` as should release the stream, making it impossible to resume from this position again.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/media/tv/interactive/TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_BLANK` - `https://developer.android.com/reference/android/media/tv/interactive/TvInteractiveAppService#COMMAND_PARAMETER_VALUE_STOP_MODE_FREEZE` |

### onSurfaceChanged

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSurfaceChanged (int format, 
                int width, 
                int height)
```

Called after any structural changes (format or size) have been made to the surface passed in `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)`. This method is always called at least once, after `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onSetSurface(android.view.Surface)` is called with non-null surface.

<br />

| Parameters ||
|---|---|
| `format` | `int`: The new PixelFormat of the surface. <br /> |
| `width` | `int`: The new width of the surface. <br /> |
| `height` | `int`: The new height of the surface. <br /> |

### onTimeShiftGetCurrentPosition

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long onTimeShiftGetCurrentPosition ()
```

Returns the current position for time shifting, in milliseconds since the epoch. Returns `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_INVALID_TIME` if the position is unknown at the moment.

The current position for time shifting is the same as the current position of playback. It should be equal to or greater than the start position reported by `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`. When playback is completed, the current position should stay where the playback ends, in other words, the returned value of this mehtod should be equal to the start position plus the duration of the program.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`

### onTimeShiftGetStartPosition

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long onTimeShiftGetStartPosition ()
```

Returns the start position for time shifting, in milliseconds since the epoch. Returns `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_INVALID_TIME` if the position is unknown at the moment.

The start position for time shifting indicates the earliest possible time the user can seek to. Initially this is equivalent to the time when the implementation starts recording. Later it may be adjusted because there is insufficient space or the duration of recording is limited by the implementation. The application does not allow the user to seek to a position earlier than the start position.

For playback of a recorded program initiated by `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`, the start position should be 0 and does not change.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTimeShiftPause

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftPause ()
```

Called when the application requests to pause playback.

<br />

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTimeShiftPlay

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftPlay (Uri recordedProgramUri)
```

Called when the application requests to play a given recorded TV program.

<br />

| Parameters ||
|---|---|
| `recordedProgramUri` | `Uri`: The URI of a recorded TV program. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTimeShiftResume

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftResume ()
```

Called when the application requests to resume playback.

<br />

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTimeShiftSeekTo

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftSeekTo (long timeMs)
```

Called when the application requests to seek to a specified time position. Normally, the position is given within range between the start and the current time, inclusively. The implementation is expected to seek to the nearest time position if the given position is not in the range.

<br />

| Parameters ||
|---|---|
| `timeMs` | `long`: The time position to seek to, in milliseconds since the epoch. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSetPlaybackParams(android.media.PlaybackParams)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTimeShiftSetMode

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftSetMode (int mode)
```

Called when the application sets time shift mode.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: The time shift mode. The value is one of the following: `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO`. Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_OFF` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_LOCAL` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_NETWORK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TIME_SHIFT_MODE_AUTO` |

### onTimeShiftSetPlaybackParams

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTimeShiftSetPlaybackParams (PlaybackParams params)
```

Called when the application sets playback parameters containing the speed and audio mode.

Once the playback parameters are set, the implementation should honor the current settings until the next tune request. Pause/resume/seek request does not reset the parameters previously set.

<br />

| Parameters ||
|---|---|
| `params` | `PlaybackParams`: The playback params. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPlay(android.net.Uri)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftResume()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftPause()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftSeekTo(long)`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetStartPosition()`
- `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTimeShiftGetCurrentPosition()`

### onTouchEvent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onTouchEvent (MotionEvent event)
```

Implement this method to handle touch screen motion events on the current input session.

<br />

| Parameters ||
|---|---|
| `event` | `MotionEvent`: The motion event being received. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onTouchEvent(android.view.MotionEvent)`

### onTrackballEvent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onTrackballEvent (MotionEvent event)
```

Implement this method to handle trackball events on the current input session.

<br />

| Parameters ||
|---|---|
| `event` | `MotionEvent`: The motion event being received. <br /> |

| Returns ||
|---|---|
| `boolean` | If you handled the event, return `true`. If you want to allow the event to be handled by the next receiver, return `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onTrackballEvent(android.view.MotionEvent)`

### onTune

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onTune (Uri channelUri, 
                Bundle params)
```

Tunes to a given channel. Override this method in order to handle domain-specific features that are only known between certain TV inputs and their clients.

The default implementation calls `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onTune(android.net.Uri)`.

<br />

| Parameters ||
|---|---|
| `channelUri` | `Uri`: The URI of the channel. <br /> |
| `params` | `Bundle`: Domain-specific data for this tune request. Keys *must* be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting keys. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the tuning was successful, `false` otherwise. <br /> |

### onTune

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean onTune (Uri channelUri)
```

Tunes to a given channel.

No video will be displayed until `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoAvailable()` is called. Also, `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyVideoUnavailable(int)` should be called when the TV input cannot continue playing the given channel.

<br />

| Parameters ||
|---|---|
| `channelUri` | `Uri`: The URI of the channel. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the tuning was successful, `false` otherwise. <br /> |

### onTvAdSessionData

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTvAdSessionData (String type, 
                Bundle data)
```

Called when data from the linked `https://developer.android.com/reference/android/media/tv/ad/TvAdService` is received.

<br />

| Parameters ||
|---|---|
| `type` | `String`: the type of the data. This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_AD_REQUEST` - `https://developer.android.com/reference/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_AD_BUFFER_READY` - `https://developer.android.com/reference/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_BROADCAST_INFO_REQUEST` - `https://developer.android.com/reference/android/media/tv/ad/TvAdManager#SESSION_DATA_TYPE_REMOVE_BROADCAST_INFO_REQUEST` |
| `data` | `Bundle`: a bundle contains the data received. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/tv/ad/TvAdService.Session#sendTvAdSessionData(java.lang.String,%20android.os.Bundle)`
- `https://developer.android.com/reference/android/media/tv/ad/TvAdView#setTvView(android.media.tv.TvView)`

### onTvMessage

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTvMessage (int type, 
                Bundle data)
```

Called when a TV message is received

<br />

| Parameters ||
|---|---|
| `type` | `int`: The type of message received, such as `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_WATERMARK` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION` - `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_TYPE_OTHER` |
| `data` | `Bundle`: The raw data of the message. The bundle keys are: `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_STREAM_ID`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_GROUP_ID`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE`, `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_RAW_DATA`. See `https://developer.android.com/reference/android/media/tv/TvInputManager#TV_MESSAGE_KEY_SUBTYPE` for more information on how to parse this data. This value cannot be `null`. <br /> |

### onUnblockContent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUnblockContent (TvContentRating unblockedRating)
```

Requests to unblock the content according to the given rating.

The implementation should unblock the content. TV input service has responsibility to decide when/how the unblock expires while it can keep previously unblocked ratings in order not to ask a user to unblock whenever a content rating is changed. Therefore an unblocked rating can be valid for a channel, a program, or certain amount of time depending on the implementation.

<br />

| Parameters ||
|---|---|
| `unblockedRating` | `TvContentRating`: An unblocked content rating <br /> |

### sendTvInputSessionData

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void sendTvInputSessionData (String type, 
                Bundle data)
```

Sends data related to this session to corresponding linked `https://developer.android.com/reference/android/media/tv/ad/TvAdService` object via TvAdView.

Methods like `https://developer.android.com/reference/android/media/tv/TvInputService.Session#notifyBroadcastInfoResponse(android.media.tv.BroadcastInfoResponse)` sends the related data to linked `https://developer.android.com/reference/android/media/tv/interactive/TvInteractiveAppService`, but don't work for `https://developer.android.com/reference/android/media/tv/ad/TvAdService`. The method is used specifically for `https://developer.android.com/reference/android/media/tv/ad/TvAdService` use cases.

<br />

| Parameters ||
|---|---|
| `type` | `String`: data type. This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TUNED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TRACK_SELECTED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TRACKS_CHANGED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_VIDEO_AVAILABLE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_VIDEO_UNAVAILABLE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_BROADCAST_INFO_RESPONSE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_AD_RESPONSE` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_AD_BUFFER_CONSUMED` - `https://developer.android.com/reference/android/media/tv/TvInputManager#SESSION_DATA_TYPE_TV_MESSAGE` |
| `data` | `Bundle`: the related data values. This value cannot be `null`. <br /> |

### setOverlayViewEnabled

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOverlayViewEnabled (boolean enable)
```

Enables or disables the overlay view.

By default, the overlay view is disabled. Must be called explicitly after the session is created to enable the overlay view.

The TV input service can disable its overlay view when the size of the overlay view is insufficient to display the whole information, such as when used in Picture-in-picture. Override `https://developer.android.com/reference/android/media/tv/TvInputService.Session#onOverlayViewSizeChanged(int,%20int)` to get the size of the overlay view, which then can be used to determine whether to enable/disable the overlay view.

<br />

| Parameters ||
|---|---|
| `enable` | `boolean`: `true` if you want to enable the overlay view. `false` otherwise. <br /> |