【问题标题】:Permission exception even though permission is set in manifest [duplicate]即使在清单中设置了权限,权限异常[重复]
【发布时间】:2016-01-23 20:48:22
【问题描述】:

在我的清单中我有:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

但是,当我运行我的应用并按下需要此权限的按钮时,我得到以下异常:

Geofence usage requires ACCESS_FINE_LOCATION permission

我该如何解决这个问题?

我有&lt;manifest&gt;下的权限

我使用的是 Android 6。

这是我的代码:

   public void addGeofencesButtonHandler(View view) {
        if (!mGoogleApiClient.isConnected()) {
            Toast.makeText(this, getString(R.string.not_connected), Toast.LENGTH_SHORT).show();
            return;
        }

        try {
            LocationServices.GeofencingApi.addGeofences(
                    mGoogleApiClient,
                    // The GeofenceRequest object.
                    getGeofencingRequest(),
                    // A pending intent that that is reused when calling removeGeofences(). This
                    // pending intent is used to generate an intent when a matched geofence
                    // transition is observed.
                    getGeofencePendingIntent()
            ).setResultCallback(this); // Result processed in onResult().
        } catch (SecurityException securityException) {
            // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
            logSecurityException(securityException);
        }
    }

【问题讨论】:

  • 也许您在 Manifest 中将您的权限放入了错误的Element
  • 我有下的权限
  • 发布您的完整清单,您使用的是 6.0 吗?
  • 是的,我使用的是 6.0。

标签: android google-play-services geofencing android-geofence


【解决方案1】:

为 API 23 编译时,您必须请求该权限。

有一篇很好的博客文章:http://android-developers.blogspot.de/2015/09/google-play-services-81-and-android-60.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 2018-03-08
    相关资源
    最近更新 更多