Android APIs
public final class

TvInputManager

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

Class Overview

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

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.
int INPUT_STATE_CONNECTED The TV input is connected.
int INPUT_STATE_CONNECTED_STANDBY The TV input is connected but in standby mode.
int INPUT_STATE_DISCONNECTED The TV input is disconnected.
String META_DATA_CONTENT_RATING_SYSTEMS Content rating systems metadata associated with ACTION_QUERY_CONTENT_RATING_SYSTEMS.
long TIME_SHIFT_INVALID_TIME
int TIME_SHIFT_STATUS_AVAILABLE Time shifting is currently available.
int TIME_SHIFT_STATUS_UNAVAILABLE Time shifting is currently not available but might work again later.
int TIME_SHIFT_STATUS_UNKNOWN Status prior to calling notifyTimeShiftStatusChanged(int).
int TIME_SHIFT_STATUS_UNSUPPORTED The TV input does not support time shifting.
int VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY Video is not available because the current program is audio-only.
int VIDEO_UNAVAILABLE_REASON_BUFFERING Video is not available because the TV input stopped the playback temporarily to buffer more data.
int VIDEO_UNAVAILABLE_REASON_TUNING Video is not available because the TV input is in the middle of tuning to a new channel.
int VIDEO_UNAVAILABLE_REASON_UNKNOWN A generic reason.
int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL Video is not available due to the 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)
void unregisterCallback(TvInputManager.TvInputCallback callback)
Unregisters the existing TvInputManager.TvInputCallback.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_BLOCKED_RATINGS_CHANGED

Added in API level 21

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"

public static final String ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED

Added in API level 21

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"

public static final String ACTION_QUERY_CONTENT_RATING_SYSTEMS

Added in API level 21

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"

public static final int INPUT_STATE_CONNECTED

Added in API level 21

The TV input 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. This is the default state for any hardware inputs where their states are unknown. Non-hardware inputs are considered connected all the time.

Constant Value: 0 (0x00000000)

public static final int INPUT_STATE_CONNECTED_STANDBY

Added in API level 21

The TV input is connected but in standby mode.

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

Constant Value: 1 (0x00000001)

public static final int INPUT_STATE_DISCONNECTED

Added in API level 21

The TV input 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)

public static final String META_DATA_CONTENT_RATING_SYSTEMS

Added in API level 21

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"

public static final long TIME_SHIFT_INVALID_TIME

Added in API level 23

Constant Value: -9223372036854775808 (0x8000000000000000)

public static final int TIME_SHIFT_STATUS_AVAILABLE

Added in API level 23

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)

public static final int TIME_SHIFT_STATUS_UNAVAILABLE

Added in API level 23

Time shifting is currently not available but might work again later.

Constant Value: 2 (0x00000002)

public static final int TIME_SHIFT_STATUS_UNKNOWN

Added in API level 23

Status prior to calling notifyTimeShiftStatusChanged(int).

Constant Value: 0 (0x00000000)

public static final int TIME_SHIFT_STATUS_UNSUPPORTED

Added in API level 23

The TV input does not support time shifting.

Constant Value: 1 (0x00000001)

public static final int VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY

Added in API level 23

Video is not available because the current program is audio-only.

Constant Value: 4 (0x00000004)

public static final int VIDEO_UNAVAILABLE_REASON_BUFFERING

Added in API level 21

Video is not available because the TV input stopped the playback temporarily to buffer more data.

Constant Value: 3 (0x00000003)

public static final int VIDEO_UNAVAILABLE_REASON_TUNING

Added in API level 21

Video is not available because the TV input is in the middle of tuning to a new channel.

Constant Value: 1 (0x00000001)

public static final int VIDEO_UNAVAILABLE_REASON_UNKNOWN

Added in API level 21

A generic reason. Video is not available due to an unspecified error.

Constant Value: 0 (0x00000000)

public static final int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL

Added in API level 21

Video is not available due to the weak TV signal.

Constant Value: 2 (0x00000002)

Public Methods

public int getInputState (String inputId)

Added in API level 21

Returns the state of a given TV input.

The state is one of the following:

Parameters
inputId The id of the TV input.
Throws
IllegalArgumentException if the argument is null.

public TvInputInfo getTvInputInfo (String inputId)

Added in API level 21

Returns the TvInputInfo for a given TV input.

Parameters
inputId The ID of the TV input.
Returns
  • the TvInputInfo for a given TV input. null if not found.

public List<TvInputInfo> getTvInputList ()

Added in API level 21

Returns the complete list of TV inputs on the system.

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

public boolean isParentalControlsEnabled ()

Added in API level 21

Returns the user's parental controls enabled state.

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

public boolean isRatingBlocked (TvContentRating rating)

Added in API level 21

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

Parameters
rating The TV content rating to check. Can be UNRATED.
Returns
  • true if the given TV content rating is blocked, false otherwise.

public void registerCallback (TvInputManager.TvInputCallback callback, Handler handler)

Added in API level 21
Parameters
callback A callback used to monitor status of the TV inputs.
handler A Handler that the status change will be delivered to.

public void unregisterCallback (TvInputManager.TvInputCallback callback)

Added in API level 21

Unregisters the existing TvInputManager.TvInputCallback.

Parameters
callback The existing callback to remove.