我有一个带有 2 个 View (屏幕)的简单 Android 应用程序。
我正在尝试让我的应用程序也能在 Android TV 上运行。我不知道我做错了什么,但是当我在模拟器上运行我的应用程序时,我看不到我的应用程序徽标。
我的 list 文件有什么问题:
<?xml version="1" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx.flagmaster">
<uses-feature android:name="android.software.leanback"
android:required="false" />
<uses-feature android:name="android.hardware.touchscreen"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
<application
android:allowBackup="true"
android:icon="@drawable/flagmasterlogo"
android:label="@string/app_name"
android:banner="@drawable/flagmastertv"
android:supportsRtl="true">
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FlagShowActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<intent-filter>
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
最佳答案
尝试检查您的 list 、您的图标(位置和大小)和您的应用程序 gradle 文件。我尝试使用基本事件(android)创建一个项目,然后添加:
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:leanback-v17:23.4.0'
对于 android TV 支持并更新了我的 list :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package_name.tvapp">
<uses-permission android:name="android.permission.INTERNET" />
<!-- TV app need to declare touchscreen not required -->
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<!--
true: your app runs on only TV
false: your app runs on phone and TV
-->
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这是电视模拟器的示例屏幕截图。注意:我不拥有图标图像,它仅用于测试目的。
以下是项目树供引用:
供引用:
关于android-manifest - 如何将我的应用程序转换为 Android TV 应用程序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39319333/