[英]How do we make Launcher/Home android app for AndroidTV device?
我在 Manifest.xml 文件中做了
<!-- Start For Android Tv Box-->
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<uses-feature
android:name="android.software.live_tv"
android:required="false" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<!-- End For Android Tv Box-->
MainActivity 是我的第一个活动,它是我的应用程序中最火的屏幕。
<activity
android:name=".MainActivity"
android:hardwareAccelerated="false"
android:screenOrientation="landscape"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:launchMode="singleInstance"
android:autoRemoveFromRecents="true"
android:resumeWhilePausing="true"
android:resizeableActivity="true"
tools:targetApi="n">
<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>
<meta-data android:name="supports_leanback" android:value="true" />
</activity>
当用户点击 AndroidTv 远程 Home/Launcher 弹出窗口的 Home 按钮时,应出现并选择 AndroidTv 设备的启动器应用程序,然后每当用户打开设备电源时,我的应用程序应作为启动器应用程序出现。
在 Android TV 中将应用程序作为启动器与其他 android 设备相同。 您只需要在您的活动的意图过滤器中添加一个名为android.intent.category.HOME
的类别。 使用以下几行更改您的AndroidManifest.xml
:
<activity
android:name=".MainActivity"
...>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
...
</intent-filter>
</activity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.