问题描述
在 Google Play 上更新我们的应用程序时,我得到 p>
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,你不能在 manifest 中锁定方向.
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
如果您的清单中没有锁定方向逻辑,则某些库可能会添加它.使用 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 关于缺少后倾意图的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!