问题
In my manifest I have:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
However, when I run my app and press the button that needs this permission I get the following exception:
Geofence usage requires ACCESS_FINE_LOCATION permission
How can I fix this?
I have the permission right under <manifest>
I am using Android 6.
This is my code:
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);
}
}
回答1:
When compiling for API 23 you have to ask for that Permission.
Theres a good Blog Post about that: http://android-developers.blogspot.de/2015/09/google-play-services-81-and-android-60.html
来源:https://stackoverflow.com/questions/33317195/permission-exception-even-though-permission-is-set-in-manifest