简体   繁体   English

检测 Android Go 手机

[英]Detecting Android Go phones

I have developed an application but now I would like to check at the first startup of the app if it is an Android Go phone and if so, inform the user that it is not supported.我已经开发了一个应用程序,但现在我想在第一次启动应用程序时检查它是否是 Android Go 手机,如果是,请通知用户它不受支持。

In Android it is possible to check the SDK version but is it also possible to check if it is a Go phone?在 Android 中,可以检查 SDK 版本,但也可以检查它是否是 Go 手机?

I would like to exclude Android Go phones because they do not support SYSTEM_ALERT_WINDOW which my app needs.我想排除 Android Go 手机,因为它们不支持我的应用程序需要的SYSTEM_ALERT_WINDOW

Looking on the official documentation https://developer.android.com/google/play/publishing/multiple-apks , it says that for an app to run on android Go, you need to Looking on the official documentation https://developer.android.com/google/play/publishing/multiple-apks , it says that for an app to run on android Go, you need to

To target devices running Android (Go edition), your APK needs to declare:要针对运行 Android(Go 版)的设备,您的 APK 需要声明:

<uses-feature android:name="android.hardware.ram.low" android:required="true">

target at least API Level 26, and have a higher version code than your non-Go edition APK.目标至少为 API 级别 26,并且具有比非 Go 版本 APK 更高的版本代码。

so by simply not putting the previous code in your manifest, your app will not be available for android Go.因此,只需不将前面的代码放入清单中,您的应用程序将不适用于 android Go。

You could call either你可以打电话

 ActivityManager.isLowRamDevice();

or或者

PackageManager.hasSystemFeature("FEATURE_RAM_LOW");

Both will return true if the device is running Android Go edition, and false if it's running the regular Android.如果设备运行 Android Go 版本,两者都将返回true ,如果运行常规 Android,则两者都将返回false

source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM