需要地理围栏触发程序说明吗? [英] Geofence triggering procedure explanation needed?

查看:117
本文介绍了需要地理围栏触发程序说明吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我创建了如下的地理围栏:

SO I've created geofence as below:

    GeofenceModel modelExit = new GeofenceModel.Builder("id_oi_456")
                .setTransition(Geofence.GEOFENCE_TRANSITION_DWELL)
                .setExpiration(Geofence.NEVER_EXPIRE)
                .setLatitude(40.414341)
                .setLongitude(49.928548)
                .setRadius(CLIENT_GEOFENCE_RADIUS)
                .build();


    SmartLocation.with(this).geofencing()
                .add(modelExit)
                .start(this);

我只运行一次此代码,当驻留在地理围栏内时(如预期的那样)会触发该代码.然后,我删除该代码段并重新运行该项目.但是,即使我设置了NEVER_EXPIRE,地理围栏这次也不会触发.因此,基本上我想知道的是,地理围栏存储在哪里.如果它们存储在应用程序内存之外,那么为什么删除代码段"会清除地理围栏?

I run this code once, it triggers when dwelling inside geofence (as expected). And then I delete the snippet and rerun the project. But geofence not triggered this time even if I have set NEVER_EXPIRE. So basically what I want to know is that where are the geonfences stored. In case they are stored outside app memory then why "deleting snippet" clears geofence?

推荐答案

我认为它按预期工作.要重新运行的项目将把该应用程序视为全新安装.如文档中所述-使用地理围栏最佳实践:

I think it is working as intended. The project that goes to re-run will consider the app as fresh install. As stated in the documentation - Use Best Practices for Geofencing:

如果在以下事件之后仍需要使用地理围栏,则该应用必须重新注册,因为在以下情况下系统无法恢复地理围栏:

The app must re-register geofences if they're still needed after the following events, since the system cannot recover the geofences in the following cases:

  • 设备已重新启动.该应用应监听设备的启动完成操作,然后重新注册所需的地理围栏.
  • 该应用已卸载并重新安装.
  • 该应用程序的数据已清除.
  • 已清除Google Play服务数据.
  • 该应用程序已收到GEOFENCE_NOT_AVAILABLE警报.通常在禁用NLP(Android的网络位置提供程序)后会发生这种情况.
  • The device is rebooted. The app should listen for the device's boot complete action, and then re- register the geofences required.
  • The app is uninstalled and re-installed.
  • The app's data is cleared.
  • Google Play services data is cleared.
  • The app has received a GEOFENCE_NOT_AVAILABLE alert. This typically happens after NLP (Android's Network Location Provider) is disabled.

希望这会有所帮助.

这篇关于需要地理围栏触发程序说明吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆