And*_*ker 6 android google-play android-tv leanback
在Google Play上更新我们的应用时,我得到了
You opted-in to Android TV but your APK or Android App Bundle does not have the Leanback intent
Run Code Online (Sandbox Code Playgroud)
这有点奇怪,因为我们在清单中有所有必需的组件来支持电视,即:
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
Run Code Online (Sandbox Code Playgroud)
和
<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>
Run Code Online (Sandbox Code Playgroud)
和
<application
android:banner="@drawable/tv_banner"
Run Code Online (Sandbox Code Playgroud)
(请注意,我们分享电视和手机之间的活动)
我们还包括以下gradle模块:
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:leanback-v17:27.1.1'
Run Code Online (Sandbox Code Playgroud)
该应用程序也适用于电视设备:)
现在,诚然,我们已经做了一个大的重构,所以我们的应用程序和清单的结构已经发生了很大变化.但是,我没有看到任何与Android开发文档中的要求相矛盾的内容:
https://developer.android.com/training/tv/start/start
有没有人经历过这个?或者,任何人都可以看到其他明显缺失/不正确的东西吗?
我终于找到答案了!
如果您想支持 AndroidTV,则无法在清单内锁定方向。
android:screenOrientation="landscape"
android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)
相反,您可以在 Activity 的 onCreate 中使用以下代码(或类似的代码)
requestedOrientation =
if (isPhoneDevice()) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
else ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
Run Code Online (Sandbox Code Playgroud)
如果您的清单中没有锁定方向逻辑,则可能某些库会添加它。使用 apk 工具反编译您的 apk,然后验证生成的清单。您可以用以下代码替换它:
<activity
android:name="com.yoursite.SampleActivity"
tools:replace="android:screenOrientation"
tools:node="merge"
android:screenOrientation="sensor"/>
Run Code Online (Sandbox Code Playgroud)
我希望它会有所帮助:)
编辑:我发现了另一个问题。
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
Run Code Online (Sandbox Code Playgroud)
您无法在 Android TV 上使用 ACCESS_WIFI_STATE 权限。
归档时间: |
|
查看次数: |
989 次 |
最近记录: |