如何在不使用 Leanback 库的情况下制作 Android 电视应用

How to make a Android TV app without using leanback lib

我是 Android 电视开发的新手。我想在不使用 leanback lib.But Android Studio 自动附加 leanback 选择平台作为电视时构建应用程序。我该如何删除它?

PS- 我的应用程序将在 webview 中进入 运行 。

private AdvancedWebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mWebView = (AdvancedWebView) findViewById(R.id.webview);
    mWebView.setListener(this, this);
    mWebView.loadUrl("url for app hosted on server");
}

对于电视应用来说,这是一个好的决定吗?

谢谢

Leanback 是 required 如果您想制作 Android 电视应用并将其上传到 Play 商店。

An application intended to run on TV devices must declare a launcher activity for TV in its manifest using a CATEGORY_LEANBACK_LAUNCHER intent filter. This filter identifies your app as being enabled for TV, and is required for your app to be considered a TV app in Google Play

您可以将 leanback required 设置为 false

If you are developing an app that runs on mobile (phones, wearables, tablets, etc.) as well as Android TV, set the required attribute value to false. If you set the required attribute value to true, your app will run only on devices that use the Leanback UI.

<manifest>
    <uses-feature android:name="android.software.leanback"
        android:required="false" />
    ...
</manifest>

您不需要任何 android 电视库,甚至不需要将您的项目设置为 android 电视项目即可在 android 电视播放商店中获取它。我将我的项目设置为标准应用程序(所有这些支持库都会使您的 apk 变大)。在可绘制对象中放置一个 320x180 的图标。在清单中只需添加

     <uses-feature android:name="android.software.leanback" android:required="false" />
     <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
     android:banner="@drawable/banner"
     <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>

如果您使用的是网络视图并且您的 ui 在所有平台上都相同,您可以在与常规 activity 相同的 activity 中使用 Leanback 启动器 Intent。

就是这样。