# TvInputService.RecordingSession

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

# TvInputService.RecordingSession

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/media/tv/TvInputService.RecordingSession "View this page in Kotlin")\|Java

`
public
static

abstract
class
TvInputService.RecordingSession
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

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

## Summary

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

|                                                                                                                                                                                                                                                                    ### Public methods                                                                                                                                                                                                                                                                    ||
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`          | ` `[notifyError](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int))`(int error) ` Informs the application that there is an error and this recording session is no longer able to start or continue recording.                                                                                                                                                                                                                                                                  |
| ` void`          | ` `[notifyRecordingStopped](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyRecordingStopped(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` recordedProgramUri) ` Informs the application that this recording session has stopped recording and created a new data entry in the[TvContract.RecordedPrograms](https://developer.android.com/reference/android/media/tv/TvContract.RecordedPrograms)table that describes the newly recorded program. |
| ` void`          | ` `[notifyTuned](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyTuned(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` channelUri) ` Informs the application that this recording session has been tuned to the given channel and is ready to start recording.                                                                                                                                                                                       |
| ` void`          | ` `[onAppPrivateCommand](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onAppPrivateCommand(java.lang.String,%20android.os.Bundle))`(`[String](https://developer.android.com/reference/java/lang/String)` action, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` data) ` Processes a private command sent from the application to the TV input.                                                                                                                       |
| ` void`          | ` `[onPauseRecording](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onPauseRecording(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` params) ` Called when the application requests to pause TV program recording.                                                                                                                                                                                                                               |
| ` abstract void` | ` `[onRelease](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onRelease())`() ` Called when the application requests to release all the resources held by this recording session.                                                                                                                                                                                                                                                                                                            |
| ` void`          | ` `[onResumeRecording](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onResumeRecording(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` params) ` Called when the application requests to resume TV program recording.                                                                                                                                                                                                                            |
| ` void`          | ` `[onStartRecording](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStartRecording(android.net.Uri,%20android.os.Bundle))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` programUri, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` params) ` Called when the application requests to start TV program recording.                                                                                                                               |
| ` abstract void` | ` `[onStartRecording](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStartRecording(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` programUri) ` Called when the application requests to start TV program recording.                                                                                                                                                                                                                                  |
| ` abstract void` | ` `[onStopRecording](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStopRecording())`() ` Called when the application requests to stop TV program recording.                                                                                                                                                                                                                                                                                                                               |
| ` void`          | ` `[onTune](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onTune(android.net.Uri,%20android.os.Bundle))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` channelUri, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` params) ` Called when the application requests to tune to a given channel for TV program recording.                                                                                                                             |
| ` abstract void` | ` `[onTune](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onTune(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` channelUri) ` Called when the application requests to tune to a given channel for TV program recording.                                                                                                                                                                                                                                |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Public constructors

### RecordingSession

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

```
public RecordingSession (Context context)
```

Creates a new RecordingSession.

<br />

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

## Public methods

### notifyError

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

```
public void notifyError (int error)
```

Informs the application that there is an error and this recording session is no longer able to start or continue recording. It may be called at any time after the recording session is created until[onRelease()](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onRelease())is called.

The application may release the current session upon receiving the error code through[TvRecordingClient.RecordingCallback.onError(int)](https://developer.android.com/reference/android/media/tv/TvRecordingClient.RecordingCallback#onError(int)). The session may call[notifyRecordingStopped(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyRecordingStopped(android.net.Uri))if a partially recorded but still playable program is available, before calling this method.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `error` | `int`: The error code. Should be one of the followings. - [TvInputManager.RECORDING_ERROR_UNKNOWN](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_UNKNOWN) - [TvInputManager.RECORDING_ERROR_INSUFFICIENT_SPACE](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE) - [TvInputManager.RECORDING_ERROR_RESOURCE_BUSY](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_RESOURCE_BUSY) Value is[TvInputManager.RECORDING_ERROR_UNKNOWN](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_UNKNOWN),[TvInputManager.RECORDING_ERROR_INSUFFICIENT_SPACE](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE), or[TvInputManager.RECORDING_ERROR_RESOURCE_BUSY](https://developer.android.com/reference/android/media/tv/TvInputManager#RECORDING_ERROR_RESOURCE_BUSY) <br /> |

### notifyRecordingStopped

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

```
public void notifyRecordingStopped (Uri recordedProgramUri)
```

Informs the application that this recording session has stopped recording and created a new data entry in the[TvContract.RecordedPrograms](https://developer.android.com/reference/android/media/tv/TvContract.RecordedPrograms)table that describes the newly recorded program.

The recording session must call this method in response to[onStopRecording()](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStopRecording()). The session may call it even before receiving a call to[onStopRecording()](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStopRecording())if a partially recorded program is available when there is an error.

<br />

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

### notifyTuned

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

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

Informs the application that this recording session has been tuned to the given channel and is ready to start recording.

Upon receiving a call to[onTune(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onTune(android.net.Uri)), the session is expected to tune to the passed channel and call this method to indicate that it is now available for immediate recording. When[onStartRecording(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onStartRecording(android.net.Uri))is called, recording must start with minimal delay.

<br />

|                    Parameters                     ||
|--------------|-------------------------------------|
| `channelUri` | `Uri`: The URI of a channel. <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 />                                                                                                                                                                       |

### onPauseRecording

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

```
public void onPauseRecording (Bundle params)
```

Called when the application requests to pause TV program recording. Recording must pause immediately when this method is called. If the pause request cannot be fulfilled, the session must call[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int)).

<br />

|                                             Parameters                                             ||
|----------|------------------------------------------------------------------------------------------|
| `params` | `Bundle`: Domain-specific data for recording request. This value cannot be`null`. <br /> |

### onRelease

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

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

Called when the application requests to release all the resources held by this recording session.

<br />

### onResumeRecording

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

```
public void onResumeRecording (Bundle params)
```

Called when the application requests to resume TV program recording. Recording must resume immediately when this method is called. If the resume request cannot be fulfilled, the session must call[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int)).

<br />

|                                             Parameters                                             ||
|----------|------------------------------------------------------------------------------------------|
| `params` | `Bundle`: Domain-specific data for recording request. This value cannot be`null`. <br /> |

### onStartRecording

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

```
public void onStartRecording (Uri programUri, 
                Bundle params)
```

Called when the application requests to start TV program recording. Recording must start immediately when this method is called.

The application may supply the URI for a TV program for filling in program specific data fields in the[TvContract.RecordedPrograms](https://developer.android.com/reference/android/media/tv/TvContract.RecordedPrograms)table. A non-null`programUri`implies the started recording should be of that specific program, whereas null`programUri`does not impose such a requirement and the recording can span across multiple TV programs. In either case, the application must call[TvRecordingClient.stopRecording()](https://developer.android.com/reference/android/media/tv/TvRecordingClient#stopRecording())to stop the recording.

The session must call[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int))if the start request cannot be fulfilled.

<br />

|                                                                                                                  Parameters                                                                                                                   ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `programUri` | `Uri`: The URI for the TV program to record, built by[TvContract.buildProgramUri(long)](https://developer.android.com/reference/android/media/tv/TvContract#buildProgramUri(long)). Can be`null`. <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. This value cannot be`null`. <br /> |

### onStartRecording

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

```
public abstract void onStartRecording (Uri programUri)
```

Called when the application requests to start TV program recording. Recording must start immediately when this method is called.

The application may supply the URI for a TV program for filling in program specific data fields in the[TvContract.RecordedPrograms](https://developer.android.com/reference/android/media/tv/TvContract.RecordedPrograms)table. A non-null`programUri`implies the started recording should be of that specific program, whereas null`programUri`does not impose such a requirement and the recording can span across multiple TV programs. In either case, the application must call[TvRecordingClient.stopRecording()](https://developer.android.com/reference/android/media/tv/TvRecordingClient#stopRecording())to stop the recording.

The session must call[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int))if the start request cannot be fulfilled.

<br />

|                                                                                                       Parameters                                                                                                       ||
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `programUri` | `Uri`: The URI for the TV program to record, built by[TvContract.buildProgramUri(long)](https://developer.android.com/reference/android/media/tv/TvContract#buildProgramUri(long)). Can be`null`. <br /> |

### onStopRecording

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

```
public abstract void onStopRecording ()
```

Called when the application requests to stop TV program recording. Recording must stop immediately when this method is called.

The session must create a new data entry in the[TvContract.RecordedPrograms](https://developer.android.com/reference/android/media/tv/TvContract.RecordedPrograms)table that describes the newly recorded program and call[notifyRecordingStopped(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyRecordingStopped(android.net.Uri))with the URI to that entry. If the stop request cannot be fulfilled, the session must call[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int)).

<br />

### onTune

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

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

Called when the application requests to tune to a given channel for TV program recording. Override this method in order to handle domain-specific features that are only known between certain TV inputs and their clients.

The application may call this method before starting or after stopping recording, but not during recording. The default implementation calls[onTune(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#onTune(android.net.Uri)).

The session must call[notifyTuned(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyTuned(android.net.Uri))if the tune request was fulfilled, or[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int))otherwise.

<br />

|                                                                                                    Parameters                                                                                                     ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `channelUri` | `Uri`: The URI of a 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 /> |

### onTune

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

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

Called when the application requests to tune to a given channel for TV program recording.

The application may call this method before starting or after stopping recording, but not during recording.

The session must call[notifyTuned(android.net.Uri)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyTuned(android.net.Uri))if the tune request was fulfilled, or[notifyError(int)](https://developer.android.com/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int))otherwise.

<br />

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