问题
I have a simple Android application with 2 views (screens). I'm trying to make my app working on Android TV as well. I don't know what am I doing wrong, but when I run my app on an emulator I don't see my app's logo.
What is wrong in my manifest file:
<?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>
回答1:
Try checking your manifest, your icon (location and size) and your app gradle file. I tried creating a project with a basic activity(android) then added:
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:leanback-v17:23.4.0'
For android TV support and updated my manifest:
<?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>
Here is the sample screenshot of the TV emulator. NOTE: I do not own the icon image, it is for testing purposes only.
Here is the project tree for reference:
For references:
- Android TV and Google Cast Development
- Get Started with TV Apps
来源:https://stackoverflow.com/questions/39319333/how-to-convert-my-app-to-an-android-tv-app