从Android TV(Oreo)中的频道单击后打开应用程序

时间:2019-04-09 02:24:58

标签: android android-tv

在此图像中:

enter image description here

我检查了:

  • 1号和3号:可以单击并打开

在数字3中,它们是应用程序

我也在开发自己的应用程序,并可以显示在数字3中。

但是我的应用无法单击并打开

请建议我在哪个位置定义属性,以使我可以直接点击并打开应用?

谢谢

1 个答案:

答案 0 :(得分:1)

经过研究,我发现this Document可以做。

  • 必须使用:setAppLinkIntentUri()方法

  • 重新安装应用

作为下面的代码

// NOTE : THESE INFO MUST MATCH WITH DATA IN MANIFEST.XML
    String SCHEME = "xxx";
    String HOST = "xxx";
    String PATH = "xxx";

    ComponentName componentName = new ComponentName(context, MainActivity.class.getName());
    String channelInputId = TvContractCompat.buildInputId(componentName);

    // Design Channel Data on Launcher in here
    Channel channel = new Channel.Builder()
            .setDisplayName(mContext.getString(R.string.mv_hot_title))
            .setType(TvContractCompat.Channels.TYPE_PREVIEW)
            .setInputId(channelInputId)
            .setAppLinkIntentUri(Uri.parse(SCHEME + "://" + HOST + "/" + PATH))
            .build();