我正在尝试使用地理围栏,但我不想获取用户的确切位置。所以我正在使用 ACCESS_COARSE_LOCATION。如果我使用大型地理围栏点圆,我认为 ACCESS_COARSE_LOCATION 将正常工作。可能工作不完美,但它可以大致了解用户位置。
在这样的文档代码
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);
}
但它给出了错误,因为 GeofencingApi.addGeofences 需要 FINE_LOCATION 权限。如何将地理围栏与 COARSA_LOCATION 结合使用
最佳答案
你不能。
您需要 ACCESS_FINE_LOCATION
才能使用地理围栏 API。
引用文档:
The first step in requesting geofence monitoring is to request the necessary permission. To use geofencing, your app must request ACCESS_FINE_LOCATION.
https://developer.android.com/training/location/geofencing.html#RequestGeofences
关于android - 如何仅通过 ACCESS_COARSE_LOCATION 使用 GeofencingApi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43574951/