Android APIs
public abstract class

TvInputService.Session

extends Object
implements KeyEvent.Callback
java.lang.Object
   ↳ android.media.tv.TvInputService.Session

Class Overview

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

Summary

Public Constructors
TvInputService.Session()
Public Methods
View onCreateOverlayView()
Called when an application requests to create an overlay view.
boolean onGenericMotionEvent(MotionEvent event)
Implement this method to handle generic motion events on the current input session.
boolean onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyDown(): always returns false (doesn't handle the event).
boolean onKeyLongPress(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).
boolean onKeyMultiple(int keyCode, int count, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).
boolean onKeyUp(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyUp(): always returns false (doesn't handle the event).
abstract void onRelease()
Called when the session is released.
abstract void onSetStreamVolume(float volume)
Sets the relative stream volume of the current TV input session to handle the change of audio focus by setting.
abstract boolean onSetSurface(Surface surface)
Sets the Surface for the current input session on which the TV input renders video.
boolean onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events on the current input session.
boolean onTrackballEvent(MotionEvent event)
Implement this method to handle trackball events on the current input session.
abstract boolean onTune(Uri channelUri)
Tunes to a given channel.
void setOverlayViewEnabled(boolean enable)
Enables or disables the overlay view.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.view.KeyEvent.Callback

Public Constructors

public TvInputService.Session ()

Public Methods

public View onCreateOverlayView ()

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

Returns
  • a view attached to the overlay window

public boolean onGenericMotionEvent (MotionEvent event)

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

Parameters
event The motion event being received.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public boolean onKeyDown (int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyDown(): 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.

Parameters
keyCode The value in event.getKeyCode().
event Description of the key event.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public boolean onKeyLongPress (int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyLongPress(): 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.

Parameters
keyCode The value in event.getKeyCode().
event Description of the key event.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

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

Default implementation of KeyEvent.Callback.onKeyMultiple(): 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.

Parameters
keyCode The value in event.getKeyCode().
count The number of times the action was made.
event Description of the key event.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public boolean onKeyUp (int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyUp(): 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.

Parameters
keyCode The value in event.getKeyCode().
event Description of the key event.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public abstract void onRelease ()

Called when the session is released.

public abstract void onSetStreamVolume (float volume)

Sets the relative stream volume of the current TV input session to handle the change of audio focus by setting.

Parameters
volume Volume scale from 0.0 to 1.0.

public abstract boolean onSetSurface (Surface surface)

Sets the Surface for the current input session on which the TV input renders video.

Parameters
surface Surface an application passes to this TV input session.
Returns
  • true if the surface was set, false otherwise.

public boolean onTouchEvent (MotionEvent event)

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

Parameters
event The motion event being received.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public boolean onTrackballEvent (MotionEvent event)

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

Parameters
event The motion event being received.
Returns
  • If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

public abstract boolean onTune (Uri channelUri)

Tunes to a given channel.

Parameters
channelUri The URI of the channel.
Returns
  • true the tuning was successful, false otherwise.

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.

Parameters
enable true if you want to enable the overlay view. false otherwise.