How do I use the Android Geofencing API?

前端 未结 5 795
醉梦人生
醉梦人生 2020-12-05 03:02

I have been testing the new Google Play Geofencing service API.

I downloaded the sample code from the Android developers site. Next, I ran the example code on an And

相关标签:
5条回答
  • 2020-12-05 03:31

    I thought I'd share my results here. I too have developed a lab app that implements Google Play Services Location API and Geofence API. My results show that the location determination code has a sort of pathological inability to admit its mistakes. :)

    When a button is pressed my app creates a geofence at the current location ("curLoc") returned by the location API with a 30 meter radius. On the screen I'm displaying the distance to the geofence center ("distToCenter") by calling curLoc.distanceTo(fenceLoc) and updating it roughly every second.

    I start the app and wait until the accuracy stabilizes (normally at 10.0 meters), then press the button to create the fence. I get the "enter" event immediately. I clear the event and go for a walk and apparently enter a space-time anomaly. I walk down the block and around the corner, and the distToCenter value has only increased by about 4 meters. I go further until I'm about 300 meters from my house (judging by counting steps) and the dstToCenter gradually increases. The geofence exit event finally fires about 20 seconds AFTER the dstToCenter goes above 30 meters.

    I wait to see where the distance stabilizes and it's about 150-ish meters. I turn around and head back home and the same extreme position lag occurs. I sit down at my desk while my wormhole self is still about 90 meters away. After about 40 seconds my doppleganger gets within the fence and after about 20 more seconds I get the enter event.

    At this point I'm still somewhere on the front sidewalk (7.4 meters away), inching my way to the front door.

    NOTE: The source was "fused" throughout although I did see the GPS status bar icon come on and flash for a few seconds after I'd lost connectivity to my WiFi. What's more, the accuracy never wavered from 10.0 meters.

    LIARS!

    :)

    0 讨论(0)
  • 2020-12-05 03:32

    If you only use cellular network, the location accuracy is lower, than the accuracy of wi-fi or gps (if you open Google Maps, the blue circle is estimation of your current position - if you only use 3GP, the circle can have radius of even hundreds of meters).

    Last days I am working on an app using Geofences and I figured out the following: IMHO the geofence entry is triggered only if ALL this "location estimation circle" is inside the geofence radius, i.e. if there is 100 % chance that you entered the geofence. So it depends on how big radius you set. If you set only 10 metres, it will probably work only with GPS, never with 3GP. For 3GP you will have to set radius like 1000 metres.

    0 讨论(0)
  • 2020-12-05 03:32

    Wifi is used to help track your location. Using wifi signals and cell signals to triangulate your position is a more power efficient solution than having your GPS running constantly. Additionally it works in situations where GPS wouldn't such as heavy multipath areas and indoors.

    0 讨论(0)
  • 2020-12-05 03:42

    I tested sample geofence application, and if WiFi is Off it does not detect geofence events on version less than Android 4.3.

    Android 4.3 and above works even WiFi is Off.

    0 讨论(0)
  • 2020-12-05 03:45

    in the case network condition you must Increase the radius at least 1000 M ,because using network provider to retrieving the current location,it take location from near by network tower.but in the case of GPS and wifi condition it works more accurate(1 M also).

    0 讨论(0)
提交回复
热议问题