Google Play警告有关缺少回甩意图的警告 [英] Google Play warning about missing leanback intent

查看:88
本文介绍了Google Play警告有关缺少回甩意图的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Play上更新我们的应用时,我会得到

When updating our app on Google Play I get

You opted-in to Android TV but your APK or Android App Bundle does not have the Leanback intent

这有点奇怪,因为清单中具有支持电视的所有必需组件,即:

This is somewhat bizarre as we have all the required components in our manifest to support TV, namely:

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

    <activity
        android:name=".MainActivity"
        android:configChanges="orientation"
        android:launchMode="singleTop"
        android:screenOrientation="behind"
        android:theme="@style/AppTheme.Splash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        </intent-filter>
    </activity>

<application
    android:banner="@drawable/tv_banner"

(请注意,我们在电视和移动设备之间共享活动)

(Note that we share the activity between TV and mobile)

我们还包括以下gradle模块:

We include the following gradle modules as well:

implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:leanback-v17:27.1.1'

该应用程序还可以在电视设备上运行:)

The app also works on TV devices :)

现在,不可否认,我们已经进行了大的重构,因此我们的应用程序和清单的结构已发生了很大变化.但是,我看不到任何与Android开发文档中的要求相抵触的东西:

Now, admittedly we've done a big refactor so the structure of our app and manifest has changed a lot. However, I don't see anything that contradicts the requirements in the Android development docs:

https://developer.android.com/training/tv/start/start

有人经历过吗?或者,任何人都可以看到其他明显的缺失/不正确的东西吗?

Has anyone experienced this? Alternatively, can anyone see anything else obvious which is missing/incorrect?

推荐答案

最后我找到了答案!

如果您想支持AndroidTV,则无法在清单中锁定方向.

If you want to support AndroidTV you cannot lock orientation inside manifest.

android:screenOrientation="landscape"
android:screenOrientation="portrait"

相反,您可以在Activity的onCreate内使用以下代码(或类似内容)

Instead, you can use below code (or something similar) inside Activity's onCreate

requestedOrientation =
        if (isPhoneDevice()) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        else ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE

如果清单中没有锁定定向逻辑,则可能有一些lib添加了它.使用apk工具反编译您的apk,然后验证生成的清单.您可以将其替换为以下代码:

If there is no locking orientation logic in your manifest maybe some lib adds it. Decompile your apk using apk tool and then verify generated manifest. You can replace it with this code:

<activity
            android:name="com.yoursite.SampleActivity"
            tools:replace="android:screenOrientation"
            tools:node="merge"
            android:screenOrientation="sensor"/>

我希望它会有所帮助:)

I hope it will help :)

我发现了另一个问题.

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

您不能在Android TV上使用ACCESS_WIFI_STATE权限.

You cannot use ACCESS_WIFI_STATE permission on Android TV.

这篇关于Google Play警告有关缺少回甩意图的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆