gpt4 book ai didi

android - 如何仅通过 ACCESS_COARSE_LOCATION 使用 GeofencingApi

转载 作者:搜寻专家 更新时间:2023-11-01 09:35:31 26 4
gpt4 key购买 nike

我正在尝试使用地理围栏,但我不想获取用户的确切位置。这样我就可以使用 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 才能使用 Geofencing 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com