【发布时间】:2019-05-30 09:01:53
【问题描述】:
我有一个依赖于地理围栏技术的功能有一个奇怪的问题。添加地理围栏时,客户端需要花费大量时间来添加(查看日志)。这很奇怪,因为它在早期工作得很好(没有与位置相关的代码更改和所有 afaik),没有任何延迟。
我正在使用以下依赖项:
'com.google.android.gms:play-services-location:16.0.0'
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION)
fun addGeoFences(
geoFences: ArrayList<Geofence>,
onSuccess: () -> Unit = {},
onFailure: (Exception) -> Unit = {}
): Boolean {
if (isAddingGeofence) {
GlobalLoggerUtils.showLog(TAG, "isAddingGeofence: $isAddingGeofence")
return false
}
GlobalLoggerUtils.showLog(TAG, "addGeoFences()")
if (geoFences.size == 0) {
return false
}
isAddingGeofence = true
geoFencingClient
.addGeofences(
getGeoFencingRequest(geoFences),
geoFencePendingIntent
).addOnSuccessListener { result ->
isAddingGeofence = false
}
.addOnFailureListener { exception ->
isAddingGeofence = false
}
.addOnCanceledListener {
isAddingGeofence = false
}
return true
}
2019-05-30 12:43:29.716 I/: addGeoFences()
2019-05-30 12:44:00.602 I/: isAddingGeofence: true
2019-05-30 12:44:02.424 I/: isAddingGeofence: true
2019-05-30 12:44:03.525 I/: isAddingGeofence: true
2019-05-30 12:44:04.975 I/: isAddingGeofence: true
2019-05-30 12:44:06.541 I/: isAddingGeofence: true
2019-05-30 12:48:18.384 I/: add success >>> result: null
2019-05-30 12:48:18.393 I/: add success >>> requestIds: XYZ
让我知道是否需要在此问题的上下文中添加任何内容。根据official Android documentation 添加地理围栏。
编辑 #1:2019 年 6 月 5 日
看起来这种情况只发生在开发版本中。工作正常 从 Play 商店安装的发布版本。
【问题讨论】:
标签: android kotlin google-play-services android-geofence