【问题标题】:Detect programmatically if "Let Google apps access your location" disabled以编程方式检测“让 Google 应用访问您的位置”是否已禁用
【发布时间】:2014-05-29 18:30:48
【问题描述】:

有谁知道您是否可以通过编程方式检查“让 Google 应用访问您的位置”的状态?

我想检查该选项是否被禁用,在这种情况下,显示“Google 应用位置设置”以让用户启用该选项。

Google Apps 位置设置屏幕截图,此对话框位于“系统设置”->“帐户”->“Google”下

【问题讨论】:

  • 将图像托管在公共图像托管站点中,并在此处仅提供链接。
  • @HKane 你是怎么解决这个问题的?

标签: android location google-apps


【解决方案1】:

在这里,您可以通过以下代码执行此操作。

将此方法复制到您使用谷歌服务的地方

boolean servicesOK() {
    int isAvailable = GooglePlayServicesUtil
            .isGooglePlayServicesAvailable(this);

    if (isAvailable == ConnectionResult.SUCCESS) {
        return true;
    } else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable,
                this, AtlastActivity.GPS_ERRORDIALOG_REQUEST);
        dialog.show();
    } else {

    }

在你想检查的地方做这个

if(Servicesok(){
// DO SOMETHING

}else{
//DO Something Else
}

【讨论】:

  • 这里是 GPS ErrorDialog Req public static final int GPS_ERRORDIALOG_REQUEST = 9001;
  • 该代码没有显示我正在寻找的对话框。查看问题中的图片。
  • 此代码检查是否安装了 Google Play 服务库,但不检查是否启用了 Google Play 服务位置...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-30
  • 2012-04-11
相关资源
最近更新 更多