java - 如何检查设备是否启用谷歌移动服务?
问题描述
我必须检查设备上的谷歌服务是否处于活动状态。我怎样才能检查它?只看玩服务就够了?
我需要这个检查华为服务。
解决方案
您应该使用GoogleApiAvailability
API。GooglePlayServicesUtil
API 已弃用,请勿使用。
爪哇:
public boolean isGooglePlayServicesAvailable(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS;
}
科特林:
fun Context.isGooglePlayServicesAvailable(): Boolean =
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS
推荐阅读
- groovy - 指导:将并行增量嵌套循环转换为流
- c# - 是否可以将 asp.net core 2.1 web api 与 sql server 中的现有数据库连接?
- java - getResponseAsStream - InputStream 指向什么?
- sql - 从sql server中的表中获取前n行
- entity-framework - Linq to Entity Group 后跟 Min
- android - 如何在三星的 Android SDK S-Pen Composer 中进行复制、粘贴和剪切
- simulink - 在 Simulink/System Generator 中为黑匣子配置时钟信号
- java - Thymeleaf 无法识别我的字段获取方法
- powershell - Powershell WMI 获取超过 30 天的软件
- python - OpenCV findContours的顺序相反