简体   繁体   English

Android 地理围栏:频繁出现不正确的 EXIT/ENTER 事件,而设备实际上是固定在围栏内

[英]Android Geofencing: frequent incorrect EXIT/ENTER events whereas device is actually stationary in fence

I am working on an app that has geofencing features, using the Google Play Services APIs .我正在使用Google Play Services API 开发具有地理围栏功能的应用程序

It works pretty well in general, except I frequently receive "false positives", meaning I receive EXIT events quickly followed by ENTER events, even when the device is actually inside the geofence and didn't move.它通常工作得很好,除了我经常收到“误报”,这意味着我会很快收到 EXIT 事件,然后是 ENTER 事件,即使设备实际上在地理围栏内并且没有移动。

The situation improved a bit when I started listening to DWELL events instead of ENTER (with a loitering time of 3 minutes).当我开始收听 DWELL 事件而不是 ENTER(徘徊时间为 3 分钟)时,情况有所改善。 I use a radius of 100m for the fences.我使用 100m 的半径作为围栏。

But when doing this, I still receive the incorrect EXIT events.但是这样做时,我仍然收到不正确的 EXIT 事件。 Ideally I would love to have the equivalent of the loitering time, but for EXIT events (the ability to be notified of EXIT events only if the device has been seen out of the fence at least for x minutes).理想情况下,我希望拥有与游荡时间相同的时间,但对于 EXIT 事件(只有在设备离开围栏至少 x 分钟后才能收到 EXIT 事件通知)。 I think this would solve the problem;我认为这可以解决问题; unfortunately the API doesn't have such feature.不幸的是,API 没有这样的功能。

Is this problem a common one, and what can be done to resolve it?这个问题是否普遍存在,可以采取什么措施来解决?

The problem occurs when determening the current geo-location depends on the cell-phone-towers where your cellphone is connected to.当确定当前地理位置取决于您的手机所连接的手机塔时,就会出现问题。 if your phone switches the cell-towers and these are far away from each other the google serverice assumes that you have moved.如果您的手机切换了手机信号塔并且这些信号塔彼此相距很远,则 google serverice 会假设您已移动。

I have solved a similar problem by introducing a time delay before reacting to event:我通过在对事件做出反应之前引入时间延迟解决了类似的问题:

A timer is cleared (if active) and then started if an event occurs.计时器被清除(如果活动),然后在事件发生时启动。

the eventhandling is done when the timer event occurs and only if the new event state is different from the previos event state事件处理在计时器事件发生时完成,并且仅当新事件状态与之前的事件状态不同时

Example: if your timer has a delay of 5 minutes all event changes below the delay time will be ignored.示例:如果您的计时器有 5 分钟的延迟,则所有低于延迟时间的事件更改都将被忽略。 if previos timer event was enter and new timer event is enter do nothing.如果输入了先前的计时器事件并且输入了新的计时器事件,则什么都不做。

I have experienced a similar issue.我遇到过类似的问题。 I am currently experimenting with several solution.我目前正在试验几种解决方案。 One is using https://pathsense.com .一种是使用https://pathsense.com The other is to filter out geofence event base on the accuracy of the triggering location.另一种是根据触发位置的准确性过滤地理围栏事件。 According to k3b's theory, the geofence event is triggered because of cell tower-based location.根据 k3b 的理论,地理围栏事件是由于基于蜂窝塔的位置而触发的。 If that's true, I believe that the uncertainty will be high because a single cell tower has something like a 1 mile radius.如果这是真的,我相信不确定性会很高,因为单个蜂窝塔的半径大约为 1 英里。 It could also be disproved if you set your Location Mode to Sensor Only, that way it only uses the GPS for data.如果您将位置模式设置为仅传感器,它也可能会被驳回,这样它只会使用 GPS 获取数据。

I have yet to conclude anything from my test so far.到目前为止,我还没有从我的测试中得出任何结论。 Using the filtering that I mentioned, I have been able to reduce false-positives by approximately 80%, but it still happens on a daily basis, which is unacceptable as a consumer app.使用我提到的过滤,我已经能够将误报减少大约 80%,但它仍然每天都会发生,这对于消费者应用程序来说是不可接受的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM