当我测试我的应用程序时:
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<application
android:name="removed"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:banner="@mipmap/banner"
android:theme="@style/AppTheme">
<activity
android:name=".MyActivity"
android:theme="@style/SplashAppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
...我还有一个函数,它在模拟器上返回true,在盒子上返回false:
public boolean isTvApp() {
PackageManager pm = getPackageManager();
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
boolean isTvAsRecommendedByGoogle = uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
@SuppressWarnings( "deprecation" )
boolean isTv01 = android.os.Build.VERSION.SDK_INT == 21 && pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION);
boolean isTv02 = android.os.Build.VERSION.SDK_INT >= 21 && pm.hasSystemFeature(PackageManager.FEATURE_LIVE_TV);
boolean hasTouchScreen = pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
boolean hasLeanback = android.os.Build.VERSION.SDK_INT >= 21 && pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
return
isTvAsRecommendedByGoogle ||
isTv01 ||
isTv02 ||
!hasTouchScreen ||
hasLeanback;
}我怎样才能让横幅在android框上工作/显示?
如何让isTvApp()为android盒工作?
发布于 2020-10-10 01:03:42
我相信原因是
UI_MODE_TYPE_TELEVISION == false
FEATURE_TELEVISION == false
FEATURE_LIVE_TV == false
FEATURE_TOUCHSCREEN == true
是因为(大多数?)android机箱具有使用鼠标(和键盘)的潜力。
鼠标基本上提供了触摸屏的功能。
我认为,我们需要把android盒看作是一台计算机,而不是电视应用程序。
我确信安卓机箱制造商会设置FEATURE_TOUCHSCREEN == true (尽管没有触摸屏),这样他们的用户就可以访问所有的应用程序(而不仅仅是有<uses-feature android:name="android.hardware.touchscreen" android:required="false" />的应用程序)。
考虑到这一点,我不确定是否最好把所有的Android机箱当作是安卓电视。(你可能会把功能限制在那些真正像电脑一样使用它的人身上)。
https://stackoverflow.com/questions/45426925
复制相似问题