【发布时间】:2022-01-24 19:04:04
【问题描述】:
我设置了一个地理围栏,当设备退出半径时,它会按预期触发。然而,地理围栏事件是完全空的。
override fun onReceive(context: Context, intent: Intent) {
val geofencingEvent = GeofencingEvent.fromIntent(intent)
}
- geofencingEvent.geofenceTransition 为 -1
- geofencingEvent.triggeringGeofences 为空
- geofencingEvent.triggeringLocation 为空
- geofencingEvent.hasError() 是假的
这并不奇怪,因为意图也是空的。但是地理围栏触发意图通常从哪里获取数据以帮助 GeofencingEvent.fromIntent() 构建事件?什么会出错,意图是空的? (没有动作,没有额外内容......意图 uri 看起来像这样:
intent:#Intent;launchFlags=0x10;component=de.yukiarts.test/.GeofenceBroadcastReceiver;end
我在 7 年前发现了这个 question,它描述了相同的行为而没有答案。我关注了这个documentation相当准确。有什么想法我可能做错了吗?
【问题讨论】:
标签: android kotlin broadcastreceiver android-geofence