【问题标题】:isGooglePlayServicesAvailable always returns falseisGooglePlayServicesAvailable 始终返回 false
【发布时间】:2017-10-03 19:45:58
【问题描述】:

我想使用 Google Play 服务获取位置,但每次我使用以下代码:

resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

我只会因此而得到错误的回报。当然,当我想通过

初始化一个新的位置客户端(我知道它已经过时)时
mLocationClient = new LocationClient(this, this, this);

我也只能得到错误的回复。 我的错误在哪里?是否需要在手机上更新 Google Play 服务?我已经检查了系统更新,上面有最新的。如果有帮助的话,它就是 Galaxy S5 mini。

【问题讨论】:

    标签: android google-play-services


    【解决方案1】:

    方法 isGooglePlayServicesAvailable 成功时返回 0,如下所示: https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult#SERVICE_SUCCESS

    所以,0 = 假...

    【讨论】:

      【解决方案2】:

      您遇到该错误的可能性有多种

      • 服务已过时
      • 服务被禁用/删除
      • 另一个与三星相关的错误

      我已使用此功能检查服务是否足够新,否则我将获得一个对话框并重定向到 google play 以更新它们

      private boolean checkPlayServices() {
          int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
          if (resultCode != ConnectionResult.SUCCESS) {
              if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                  GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
              }
              else {
                  finish();
              }
              return false;
          }
          return true;
      }
      

      它会显示错误。

      【讨论】:

        猜你喜欢
        • 2011-11-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-22
        • 1970-01-01
        • 2020-10-03
        • 2017-01-18
        相关资源
        最近更新 更多