【发布时间】:2016-01-23 20:48:22
【问题描述】:
在我的清单中我有:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
但是,当我运行我的应用并按下需要此权限的按钮时,我得到以下异常:
Geofence usage requires ACCESS_FINE_LOCATION permission
我该如何解决这个问题?
我有<manifest>下的权限
我使用的是 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