Example usage for android.media.tv TvInputInfo getServiceInfo

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

Introduction

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

Prototype

public ServiceInfo getServiceInfo() 

Source Link

Document

Returns the information of the service that implements this TV input.

Usage

From source file:Main.java

public static String getServiceNameFromInputId(Context context, String inputId) {
    TvInputManager tim = (TvInputManager) context.getSystemService(Context.TV_INPUT_SERVICE);
    for (TvInputInfo info : tim.getTvInputList()) {
        if (info.getId().equals(inputId)) {
            return info.getServiceInfo().name;
        }/*w ww. j a  va2s .  c  o m*/
    }
    return null;
}

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

/**
 * Starts setup activity for the given input {@code input}.
 *
 * @param calledByPopup If true, startSetupActivity is invoked from the setup fragment.
 *//*from w w w . ja v  a2  s . co m*/
public void startSetupActivity(TvInputInfo input, boolean calledByPopup) {
    Intent intent = TvCommonUtils.createSetupIntent(input);
    if (intent == null) {
        Toast.makeText(this, R.string.msg_no_setup_activity, Toast.LENGTH_SHORT).show();
        return;
    }
    // Even though other app can handle the intent, the setup launched by Live channels
    // should go through Live channels SetupPassthroughActivity.
    intent.setComponent(new ComponentName(this, SetupPassthroughActivity.class));
    try {
        // Now we know that the user intends to set up this input. Grant permission for writing
        // EPG data.
        SetupUtils.grantEpgPermission(this, input.getServiceInfo().packageName);

        mInputIdUnderSetup = input.getId();
        mIsSetupActivityCalledByPopup = calledByPopup;
        // Call requestVisibleBehind(false) before starting other activity.
        // In Activity.requestVisibleBehind(false), this activity is scheduled to be stopped
        // immediately if other activity is about to start. And this activity is scheduled to
        // to be stopped again after onPause().
        stopTv("startSetupActivity()", false);
        startActivityForResult(intent, REQUEST_CODE_START_SETUP_ACTIVITY);
    } catch (ActivityNotFoundException e) {
        mInputIdUnderSetup = null;
        Toast.makeText(this, getString(R.string.msg_unable_to_start_setup_activity, input.loadLabel(this)),
                Toast.LENGTH_SHORT).show();
        return;
    }
    if (calledByPopup) {
        mOverlayManager.hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_WITHOUT_ANIMATION
                | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_FRAGMENT);
    } else {
        mOverlayManager.hideOverlays(TvOverlayManager.FLAG_HIDE_OVERLAYS_WITHOUT_ANIMATION
                | TvOverlayManager.FLAG_HIDE_OVERLAYS_KEEP_SIDE_PANEL_HISTORY);
    }
}