即使在清单中设置了权限,权限异常也是如此 [英] Permission exception even though permission is set in manifest
问题描述
在我的清单中,我有:
<使用权限android:name =android.permission.ACCESS_FINE_LOCATION/ >
但是,当我运行我的应用程序并按下需要此权限的按钮时,出现以下异常:
地理栅栏使用需要ACCESS_FINE_LOCATION权限
我该如何解决这个问题?
我有 我使用Android 6. 这是我的代码: 编译API 23你必须要求这个权限。 这是一篇很好的博客文章: http://android-developers.blogspot.de/2015/09/google-play-services-81-and-android-60.html In my manifest I have: However, when I run my app and press the button that needs this permission I get the following exception: How can I fix this? I have the permission right under I am using Android 6. This is my code:
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 这篇关于即使在清单中设置了权限,权限异常也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< manifest> $ c $
public void addGeofencesButtonHandler(View view){
if(!mGoogleApiClient.isConnected()){
Toast.makeText(this,getString (R.string.not_connected),Toast.LENGTH_SHORT).show();
return;
尝试{
LocationServices.GeofencingApi.addGeofences(
mGoogleApiClient,
// GeofenceRequest对象。
getGeofencingRequest(),
//当调用removeGeofences()时被重用的未决意图
//待定意图用于在观察到匹配的geofence
//转换时生成意图
getGeofencePendingIntent()
).setResultCallback(this); //在onResult()中处理结果。
} catch(SecurityException securityException){
//如果应用程序未使用ACCESS_FINE_LOCATION权限,则捕获异常。
logSecurityException(securityException);
}
}
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Geofence usage requires ACCESS_FINE_LOCATION permission
<manifest>
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);
}
}