Example usage for android.media.tv TvInputInfo isHidden

List of usage examples for android.media.tv TvInputInfo isHidden

Introduction

In this page you can find the example usage for android.media.tv TvInputInfo isHidden.

Prototype

public boolean isHidden(Context context) 

Source Link

Document

Checks if this TV input is marked hidden by the user in the settings.

Usage

From source file:com.android.tv.TvApplication.java

/**
 * Handles the global key KEYCODE_TV_INPUT.
 *///w ww  . jav a2  s .  c om
public void handleTvInputKey() {
    TvInputManager tvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
    List<TvInputInfo> tvInputs = tvInputManager.getTvInputList();
    int inputCount = 0;
    boolean hasTunerInput = false;
    for (TvInputInfo input : tvInputs) {
        if (input.isPassthroughInput()) {
            if (!input.isHidden(this)) {
                ++inputCount;
            }
        } else if (!hasTunerInput) {
            hasTunerInput = true;
            ++inputCount;
        }
    }
    if (inputCount < 2) {
        return;
    }
    Activity activityToHandle = mMainActivityWrapper.isResumed() ? mMainActivityWrapper.getMainActivity()
            : mSelectInputActivity;
    if (activityToHandle != null) {
        // If startActivity is called, MainActivity.onPause is unnecessarily called. To
        // prevent it, MainActivity.dispatchKeyEvent is directly called.
        activityToHandle.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_TV_INPUT));
        activityToHandle.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_TV_INPUT));
    } else if (mMainActivityWrapper.isStarted()) {
        Bundle extras = new Bundle();
        extras.putString(Utils.EXTRA_KEY_ACTION, Utils.EXTRA_ACTION_SHOW_TV_INPUT);
        startMainActivity(extras);
    } else {
        startActivity(new Intent(this, SelectInputActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    }
}