I am working on an Android app which makes use of geofence. I want user to decide the radius of geofence. But I want to know what is the minimum and maximum radius for the geofence so that app will work fine.
For best results, the minimum radius of the geofence should be set between 100 - 150 meters.
=> When Wi-Fi is available location accuracy is usually between 20 - 50 meters.
=> When indoor location is available, the accuracy range can be as small as 5 meters. Unless you know indoor location is available inside the geofence, assume that Wi-Fi location accuracy is about 50 meters.
Check and read developer site
https://developer.android.com/training/location/geofencing.html
You can set 50-100 meters as minimum for all conditions.
The documentation doesn't actually specify a minimum or maximum but while investigating some issues I found that geofences that are smaller than 80m radius seem to be added as 80m at least on my device. I found that out using:
adb shell
dumpsys activity service com.google.android.gms/com.google.android.location.internal.GoogleLocationManagerService
That said, it's seems a little inconsistent because they sometimes trigger an exit while I am well within the 80m - almost at the edge of the 30m that was the original geofence but other times it works differently. The adb command still shows 80m.
Maximum- the radius of the earth. GPS is confirmed not to work on the moon.
Minimum- depends on the accuracy of your gps hardware, atmospheric conditions, etc. If everything is great, probably 10 meters reliably. If you fall back to network location, probably about 500 meters.
Related
It is possible make the geofence exit and enter events trigger without any location request?
Even when there is no other application requesting location, only with the device GPS turned on?
Yes, it's possible. The device can know its location from the nearby wifis and the phone signal.
The location accuracy of these methods is not as good as with a gps signal stablished but if the radius is big enough as 150m or more as it's recommended in the geofencing docs this is enough. And bigger in rural areas:
Choose the optimal radius for your geofence
For best results, the minimum radius of the geofence should be set between 100 - 150 meters. When Wi-Fi is available location accuracy is usually between 20 - 50 meters. When indoor location is available, the accuracy range can be as small as 5 meters. Unless you know indoor location is available inside the geofence, assume that Wi-Fi location accuracy is about 50 meters.
When Wi-Fi location isn't available (for example, when you are driving in rural areas) the location accuracy degrades. The accuracy range can be as large as several hundred meters to several kilometers. In cases like this, you should create geofences using a larger radius.
There are any documentation for this? I've checked many formulas and algorithms but didn't find an explicit definition how they get the speed provided in Geolocation object.
The GPS chipset provides the current velocity to the system along with the current location.
The chipset may compute the velocity by comparing location over time and correcting for the curvature of the Earth at the current location, or from the Doppler shift of the received satellite signals.
Whichever method is used, the operating system doesn’t need to do any processing to get the speed. The velocity data is provided along with location and altitude data directly from the GPS chip (actually chips in many newer devices support both GPS and GLONASS, but which system is used is not visible to the user).
Physics.org has a simple explanation of how GPS works
Wherever you are on the planet, at least four GPS satellites are ‘visible’ at any time. Each one transmits information about its position and the current time at regular intervals. These signals, travelling at the speed of light, are intercepted by your GPS receiver, which calculates how far away each satellite is based on how long it took for the messages to arrive.
Once it has information on how far away at least three satellites are, your GPS receiver can pinpoint your location using a process called trilateration.
But you can search for more detailed explanations of the mathematics and physics involved.
It basically scans your location (i.e. your latitude and longitude) and compares with the last check. Using euclidian distance, it can get the distance in the period of time. With the time (for example, if it scans your location every 2 seconds), it can easily estimate your speed by doing Speed = Distance/2.
When getting location from the android location manager, I face an issue. Even when I am sitting at a place and not moving, the latitude and longitude I get in onLocationChange() listener are always changing. I have set the update time 500ms and update distance as 5 meters. Any idea on how to fix it?
The GPS offset is arround 8 meters for normal phones and about 15-20 meters for old ones. You can set the minimum distance for more than 15 meters and it should help.
In case you are using NETWORK provider, than it takes it's locations from WiFi routers and Cellolar towers. in that case, if the phone changes a cell tower or pick up a new WiFi, than the location might change by more than then 20 meters (20-70 meters for WiFi and 500-1500 meters for cell towers).
Another thing you can do is to take into account the accuracy parameter of the locations you are getting, it should give you a rough estimate on the provider error (E.G. GPS vs Network vs WiFi) and you can try to understand if the phone is moving or not by calculating:
if (position_A.distanceTo(position_B) - position_B.getAcuracy() >0){
do something. //location change.
}
Update
see that for clarification, while the blue dot is the location your device gives you, the actual location can be anywhere in the blue radius.
Hi i am working on a real time location tracking application where i have used Fused Location provider Api. I was able to get the location updates when the device is moving. But i was also able to get the location updates even if the device is stationary on a table when i am indoor. So I have calculated the distance between the last location and the current location triggered in Onlocationchanged event and checked whether the distance is less than 30 metres, to know the device is actually moving. But sometimes the distance i get is greater than 400 metres (indoor/Device is Stationary). How Can i ignore the onlocationchange event when i am indoor? Any suggestions are appreciated.Thanks in advance.
Unfortunately I don't believe there's much you can do about it.
The reason you see those updates with great changes it's because indoors, you won't get a GPS lock, so the device is relying on cell tower and WiFi hotspot triangulation to determine your location, and something around 200m to 1km is the best you'll get with this kind of technology.
A possible attempt to hack-around it would be to:
check the source and precision of the location update
use the activity recognition API to guess if the device really moved
but both are a hack, around the technology limitation and might not be as reliable.
I implemented the new LocationClient into my app, but doing a test run I noticed the readings are incorrect.
I was driving outside without GPS. WLAN on. Thus location accuracy can only be what used to be NETWORK.
I set the LocationClient to LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY; and update interval to 15 sec.
When I get the data I evaluate the Location with getAccuracy() and getTime(). Both values can not be trusted.
I get an accuracy of 25 to 50m, sometimes up to 100 meters, typical for WIFI locations. However, once I left home, the location reported (with getAccuray() < 100) had nothing much to do with my current location (actual accuracy >800m). It resembled best the cell tower location. Location was never updated in the hour I was traveling, thus always pointing to the same cell tower (incidently I always was in that area although traveling about 3 km).
Doing further tests I noticed that location and accuracy did not change for at least a minute after I turned wifi off. I was walking, so accelerator should be triggered. Again, location was way off to where I was, but accuracy still reported < 30m. After about 1-2 Minutes, the location was then reported with accuracy >800 m which was correct.
I can live with bad accuracy, but I need to know that.
Time is always updated to latest time also while the actual reading is older. This also seems a bug, someone already raised an issue at google for that.
Summarized it means I can not use that functionality. I get old readings reported as current and accuracy which does not match the reading.
Test where done on a Nexus 4. Phone was connected to an UMTS (3G) cell.
Are these known issues? Is there a way to work around it (getting the correct accuracy), or do I have to use the "old" LocationManager?