Skip to content

Most visited

Recently visited

navigation

TvInputManager

public final class TvInputManager
extends Object

java.lang.Object
   ↳ android.media.tv.TvInputManager


Central system API to the overall TV input framework (TIF) architecture, which arbitrates interaction between applications and the selected TV inputs.

There are three primary parties involved in the TV input framework (TIF) architecture:

  • The TV input manager as expressed by this class is the central point of the system that manages interaction between all other parts. It is expressed as the client-side API here which exists in each application context and communicates with a global system service that manages the interaction across all processes.
  • A TV input implemented by TvInputService represents an input source of TV, which can be a pass-through input such as HDMI, or a tuner input which provides broadcast TV programs. The system binds to the TV input per application’s request. on implementing TV inputs.
  • Applications talk to the TV input manager to list TV inputs and check their status. Once an application find the input to use, it uses TvView or TvRecordingClient for further interaction such as watching and recording broadcast TV programs.

Instances of this class must be obtained using Context.getSystemService(Class) with the argument TvInputManager.class or Context.getSystemService(String) with the argument Context.TV_INPUT_SERVICE.

Summary

Nested classes

class TvInputManager.TvInputCallback

Callback used to monitor status of the TV inputs. 

Constants

String ACTION_BLOCKED_RATINGS_CHANGED

Broadcast intent action when the user blocked content ratings change.

String ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED

Broadcast intent action when the parental controls enabled state changes.

String ACTION_QUERY_CONTENT_RATING_SYSTEMS

Broadcast intent action used to query available content rating systems.

String ACTION_SETUP_INPUTS

Activity action to set up channel sources i.e. TV inputs of type TYPE_TUNER.

String ACTION_VIEW_RECORDING_SCHEDULES

Activity action to display the recording schedules.

int INPUT_STATE_CONNECTED

State for getInputState(String) and onInputStateChanged(String, int): The input source is connected.

int INPUT_STATE_CONNECTED_STANDBY

State for getInputState(String) and onInputStateChanged(String, int): The input source is connected but in standby mode.

int INPUT_STATE_DISCONNECTED

State for getInputState(String) and onInputStateChanged(String, int): The input source is disconnected.

String META_DATA_CONTENT_RATING_SYSTEMS

Content rating systems metadata associated with ACTION_QUERY_CONTENT_RATING_SYSTEMS.

int RECORDING_ERROR_INSUFFICIENT_SPACE

Error for notifyError(int) and onError(int): Recording cannot proceed due to insufficient storage space.

int RECORDING_ERROR_RESOURCE_BUSY

Error for notifyError(int) and onError(int): Recording cannot proceed because a required recording resource was not able to be allocated.

int RECORDING_ERROR_UNKNOWN

Error for notifyError(int) and onError(int): The requested operation cannot be completed due to a problem that does not fit under any other error codes, or the error code for the problem is defined on the higher version than application's android:targetSdkVersion.

long TIME_SHIFT_INVALID_TIME

Value returned by onTimeShiftGetCurrentPosition() and onTimeShiftGetStartPosition() when time shifting has not yet started.

int TIME_SHIFT_STATUS_AVAILABLE

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Time shifting is currently available.

int TIME_SHIFT_STATUS_UNAVAILABLE

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Time shifting is currently unavailable but might work again later.

int TIME_SHIFT_STATUS_UNKNOWN

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Unknown status.

int TIME_SHIFT_STATUS_UNSUPPORTED

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): The current TV input does not support time shifting.

int VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the current TV program is audio-only.

int VIDEO_UNAVAILABLE_REASON_BUFFERING

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the corresponding TV input has stopped playback temporarily to buffer more data.

int VIDEO_UNAVAILABLE_REASON_TUNING

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the corresponding TV input is in the middle of tuning to a new channel.

int VIDEO_UNAVAILABLE_REASON_UNKNOWN

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable due to an unspecified error.

int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable due to weak TV signal.

Public methods

int getInputState(String inputId)

Returns the state of a given TV input.

TvInputInfo getTvInputInfo(String inputId)

Returns the TvInputInfo for a given TV input.

List<TvInputInfo> getTvInputList()

Returns the complete list of TV inputs on the system.

boolean isParentalControlsEnabled()

Returns the user's parental controls enabled state.

boolean isRatingBlocked(TvContentRating rating)

Checks whether a given TV content rating is blocked by the user.

void registerCallback(TvInputManager.TvInputCallback callback, Handler handler)

Registers a TvInputManager.TvInputCallback.

void unregisterCallback(TvInputManager.TvInputCallback callback)

Unregisters the existing TvInputManager.TvInputCallback.

void updateTvInputInfo(TvInputInfo inputInfo)

Updates the TvInputInfo for an existing TV input.

Inherited methods

From class java.lang.Object

Constants

ACTION_BLOCKED_RATINGS_CHANGED

added in API level 21
String ACTION_BLOCKED_RATINGS_CHANGED

Broadcast intent action when the user blocked content ratings change. For use with the isRatingBlocked(TvContentRating).

Constant Value: "android.media.tv.action.BLOCKED_RATINGS_CHANGED"

ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED

added in API level 21
String ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED

Broadcast intent action when the parental controls enabled state changes. For use with the isParentalControlsEnabled().

Constant Value: "android.media.tv.action.PARENTAL_CONTROLS_ENABLED_CHANGED"

ACTION_QUERY_CONTENT_RATING_SYSTEMS

added in API level 21
String ACTION_QUERY_CONTENT_RATING_SYSTEMS

Broadcast intent action used to query available content rating systems.

The TV input manager service locates available content rating systems by querying broadcast receivers that are registered for this action. An application can offer additional content rating systems to the user by declaring a suitable broadcast receiver in its manifest.

Here is an example broadcast receiver declaration that an application might include in its AndroidManifest.xml to advertise custom content rating systems. The meta-data specifies a resource that contains a description of each content rating system that is provided by the application.

 <receiver android:name=".TvInputReceiver">
     <intent-filter>
         <action android:name=
                 "android.media.tv.action.QUERY_CONTENT_RATING_SYSTEMS" />
     </intent-filter>
     <meta-data
             android:name="android.media.tv.metadata.CONTENT_RATING_SYSTEMS"
             android:resource="@xml/tv_content_rating_systems" />
 </receiver>

In the above example, the @xml/tv_content_rating_systems resource refers to an XML resource whose root element is <rating-system-definitions> that contains zero or more <rating-system-definition> elements. Each <rating-system-definition> element specifies the ratings, sub-ratings and rating orders of a particular content rating system.

See also:

Constant Value: "android.media.tv.action.QUERY_CONTENT_RATING_SYSTEMS"

ACTION_SETUP_INPUTS

added in API level 24
String ACTION_SETUP_INPUTS

Activity action to set up channel sources i.e. TV inputs of type TYPE_TUNER. When invoked, the system will display an appropriate UI for the user to initiate the individual setup flow provided by setupActivity of each TV input service.

Constant Value: "android.media.tv.action.SETUP_INPUTS"

ACTION_VIEW_RECORDING_SCHEDULES

added in API level 26
String ACTION_VIEW_RECORDING_SCHEDULES

Activity action to display the recording schedules. When invoked, the system will display an appropriate UI to browse the schedules.

Constant Value: "android.media.tv.action.VIEW_RECORDING_SCHEDULES"

INPUT_STATE_CONNECTED

added in API level 21
int INPUT_STATE_CONNECTED

State for getInputState(String) and onInputStateChanged(String, int): The input source is connected.

This state indicates that a source device is connected to the input port and is in the normal operation mode. It is mostly relevant to hardware inputs such as HDMI input. Non-hardware inputs are considered connected all the time.

Constant Value: 0 (0x00000000)

INPUT_STATE_CONNECTED_STANDBY

added in API level 21
int INPUT_STATE_CONNECTED_STANDBY

State for getInputState(String) and onInputStateChanged(String, int): The input source is connected but in standby mode.

This state indicates that a source device is connected to the input port but is in standby or low power mode. It is mostly relevant to hardware inputs such as HDMI input and Component inputs.

Constant Value: 1 (0x00000001)

INPUT_STATE_DISCONNECTED

added in API level 21
int INPUT_STATE_DISCONNECTED

State for getInputState(String) and onInputStateChanged(String, int): The input source is disconnected.

This state indicates that a source device is disconnected from the input port. It is mostly relevant to hardware inputs such as HDMI input.

Constant Value: 2 (0x00000002)

META_DATA_CONTENT_RATING_SYSTEMS

added in API level 21
String META_DATA_CONTENT_RATING_SYSTEMS

Content rating systems metadata associated with ACTION_QUERY_CONTENT_RATING_SYSTEMS.

Specifies the resource ID of an XML resource that describes the content rating systems that are provided by the application.

Constant Value: "android.media.tv.metadata.CONTENT_RATING_SYSTEMS"

RECORDING_ERROR_INSUFFICIENT_SPACE

added in API level 24
int RECORDING_ERROR_INSUFFICIENT_SPACE

Error for notifyError(int) and onError(int): Recording cannot proceed due to insufficient storage space.

Constant Value: 1 (0x00000001)

RECORDING_ERROR_RESOURCE_BUSY

added in API level 24
int RECORDING_ERROR_RESOURCE_BUSY

Error for notifyError(int) and onError(int): Recording cannot proceed because a required recording resource was not able to be allocated.

Constant Value: 2 (0x00000002)

RECORDING_ERROR_UNKNOWN

added in API level 24
int RECORDING_ERROR_UNKNOWN

Error for notifyError(int) and onError(int): The requested operation cannot be completed due to a problem that does not fit under any other error codes, or the error code for the problem is defined on the higher version than application's android:targetSdkVersion.

Constant Value: 0 (0x00000000)

TIME_SHIFT_INVALID_TIME

added in API level 23
long TIME_SHIFT_INVALID_TIME

Value returned by onTimeShiftGetCurrentPosition() and onTimeShiftGetStartPosition() when time shifting has not yet started.

Constant Value: -9223372036854775808 (0x8000000000000000)

TIME_SHIFT_STATUS_AVAILABLE

added in API level 23
int TIME_SHIFT_STATUS_AVAILABLE

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Time shifting is currently available. In this status, the application assumes it can pause/resume playback, seek to a specified time position and set playback rate and audio mode.

Constant Value: 3 (0x00000003)

TIME_SHIFT_STATUS_UNAVAILABLE

added in API level 23
int TIME_SHIFT_STATUS_UNAVAILABLE

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Time shifting is currently unavailable but might work again later.

Constant Value: 2 (0x00000002)

TIME_SHIFT_STATUS_UNKNOWN

added in API level 23
int TIME_SHIFT_STATUS_UNKNOWN

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): Unknown status. Also the status prior to calling notifyTimeShiftStatusChanged.

Constant Value: 0 (0x00000000)

TIME_SHIFT_STATUS_UNSUPPORTED

added in API level 23
int TIME_SHIFT_STATUS_UNSUPPORTED

Status for notifyTimeShiftStatusChanged(int) and onTimeShiftStatusChanged(String, int): The current TV input does not support time shifting.

Constant Value: 1 (0x00000001)

VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY

added in API level 23
int VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the current TV program is audio-only.

Constant Value: 4 (0x00000004)

VIDEO_UNAVAILABLE_REASON_BUFFERING

added in API level 21
int VIDEO_UNAVAILABLE_REASON_BUFFERING

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the corresponding TV input has stopped playback temporarily to buffer more data.

Constant Value: 3 (0x00000003)

VIDEO_UNAVAILABLE_REASON_TUNING

added in API level 21
int VIDEO_UNAVAILABLE_REASON_TUNING

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable because the corresponding TV input is in the middle of tuning to a new channel.

Constant Value: 1 (0x00000001)

VIDEO_UNAVAILABLE_REASON_UNKNOWN

added in API level 21
int VIDEO_UNAVAILABLE_REASON_UNKNOWN

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable due to an unspecified error.

Constant Value: 0 (0x00000000)

VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL

added in API level 21
int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL

Reason for notifyVideoUnavailable(int) and onVideoUnavailable(String, int): Video is unavailable due to weak TV signal.

Constant Value: 2 (0x00000002)

Public methods

getInputState

added in API level 21
int getInputState (String inputId)

Returns the state of a given TV input.

The state is one of the following:

Parameters
inputId String: The ID of the TV input.

This value must never be null.

Returns
int

Throws
IllegalArgumentException if the argument is null.

getTvInputInfo

added in API level 21
TvInputInfo getTvInputInfo (String inputId)

Returns the TvInputInfo for a given TV input.

Parameters
inputId String: The ID of the TV input.

This value must never be null.

Returns
TvInputInfo the TvInputInfo for a given TV input. null if not found.

getTvInputList

added in API level 21
List<TvInputInfo> getTvInputList ()

Returns the complete list of TV inputs on the system.

Returns
List<TvInputInfo> List of TvInputInfo for each TV input that describes its meta information.

isParentalControlsEnabled

added in API level 21
boolean isParentalControlsEnabled ()

Returns the user's parental controls enabled state.

Returns
boolean true if the user enabled the parental controls, false otherwise.

isRatingBlocked

added in API level 21
boolean isRatingBlocked (TvContentRating rating)

Checks whether a given TV content rating is blocked by the user.

Parameters
rating TvContentRating: The TV content rating to check. Can be UNRATED.

This value must never be null.

Returns
boolean true if the given TV content rating is blocked, false otherwise.

registerCallback

added in API level 21
void registerCallback (TvInputManager.TvInputCallback callback, 
                Handler handler)

Registers a TvInputManager.TvInputCallback.

Parameters
callback TvInputManager.TvInputCallback: A callback used to monitor status of the TV inputs.

This value must never be null.

handler Handler: A Handler that the status change will be delivered to.

This value must never be null.

unregisterCallback

added in API level 21
void unregisterCallback (TvInputManager.TvInputCallback callback)

Unregisters the existing TvInputManager.TvInputCallback.

Parameters
callback TvInputManager.TvInputCallback: The existing callback to remove.

This value must never be null.

updateTvInputInfo

added in API level 24
void updateTvInputInfo (TvInputInfo inputInfo)

Updates the TvInputInfo for an existing TV input. A TV input service implementation may call this method to pass the application and system an up-to-date TvInputInfo object that describes itself.

The system automatically creates a TvInputInfo object for each TV input, based on the information collected from the AndroidManifest.xml, thus it is not necessary to call this method unless such information has changed dynamically. Use TvInputInfo.Builder to build a new TvInputInfo object.

Attempting to change information about a TV input that the calling package does not own does nothing.

Parameters
inputInfo TvInputInfo: The TvInputInfo object that contains new information.

This value must never be null.

Throws
IllegalArgumentException if the argument is null.

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)