Geofence triggering procedure explanation needed?

浪尽此生 提交于 2019-11-26 22:18:50

问题


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);

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?


回答1:


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:

  • 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.

Hope this helps.



来源:https://stackoverflow.com/questions/44323848/geofence-triggering-procedure-explanation-needed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!