[英]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.