android - Google Maps Android API V2 检查 Google Maps 应用程序是否被禁用

标签 android google-maps google-play-services google-maps-android-api-2

question谈论检查设备上是否安装了谷歌地图,答案是否正常。在较新版本的 Android 中,我们只能禁用 Google map 应用程序而不能将其卸载,因此上述答案对我来说并不完全适用。

当我在安装了 Google Play 服务 9.2.x 的手机上测试我的应用程序时,当 Google map 应用程序被禁用时它无法工作,这很奇怪,因为在 Google Play 服务 >= 9.4 的设备上它可以正常工作。 x.

有没有办法检查 Google map 应用程序是否被禁用? (请注意,应用程序仍处于安装状态,只是已禁用。)

最佳答案

您可以使用如下包名来检查这一点

String packageName = "com.google.android.gms.maps";
int flag = 0;
ApplicationInfo appInfo = getActivity().getPackageManager().getApplicationInfo(packageName,flag);
boolean isAppDisabled = appInfo.enabled;

阅读here更多细节。您还可以根据您的要求设置不同的标志常量,如文档链接中所述。

关于android - Google Maps Android API V2 检查 Google Maps 应用程序是否被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39362669/

相关文章:

google-maps - 使用 vue2-google-maps 创建折线

android - Google Places API 错误 - ApiException : 9008: PLACES_API_INVALID_APP

android - 如何在 getLastLocation 时间修复旧时获取一次位置

带有来自 URL 和 TextView 的 ImageView 的 Android ListView

android firebase实时数据库问题(回收器 View ,onclick按钮,删除)

android - 手机的名称/型号存储在 android 代码的哪个位置,它是如何存储在那里的?

android - logcat dalvikvm 错误消息的含义

javascript - 如何在谷歌地图中自动设置信息窗口内容

google-maps - 谷歌地图 API 3 .容器 div 未完全填满

android - 谷歌加安卓 API : "The method setActions(String[]) is undefined for the type PlusClient.Builder"