Android LocationServices strange behavior, long range wifi - android

I'm getting current location in my app by LocationServices API FusedLocationApi. Which gets location from gps, wifi and cell towers. When drawing route by geopoints I find very strange behavior in one place. Staying in this place I get points and one of them have coordinates near me and another have coordinates of a place which is more than 0.5 kilometers from me. And all points that are far from me lies in place which radius is 3-5 meters. The accuracy I get from Location method getAccuracy() is rather high.
The only reason of it I see in long range wifi. The only solution I find yet is to disable sending points of the place which radius is 3-5 meters to my server. Does anybody knows how can I identify this wifi point and ban it. I thought maybe Location method getProvider() give me some data but it allways writes "fused"))

Related

How does Apple or Android calculate speed in devices?

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.

Location change even when phone is kept on the table

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.

Check if the device is STILL (Not Moving) to ignore onlocation changed events in Android

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.

Android GPS location isn't as accurate as network location

I've got an app which sets up two location listeners (one for GPS and one for network) and then chooses the location from the best one available, which should be GPS. However, if GPS is turned on, it will always choose the GPS location, even if the person starts the app up indoors. This has led to the GPS location being used even if the last known GPS location is from miles away and the network location is actually much more accurate.
Is there any way around this issue or is it just something that will need to be accepted as an issue with using GPS & network? Is the standard practice just to assume that GPS is always more accurate even though it's possible that it might not be in certain instances?
If you are using the network provider to fetch the location they are not very accurate when compared to GPS. So it can be a good idea to fetch the accuracy of your position using network provider when you are indoors as GPS doesnt function well indoors and you can use GPS to get the location updates when you are outdoor.
You can use GetAccuracy() method of Location class and see for the value it returns. Let Say if getAccuracy() retruns 25 then you can leave this value wait for another gps value until you get the desired value. Remember the value it returns is the radius of the circle in meters.

Getting wrong location in LocationManager

I get totally wrong location when using the LocationManager with the Network provider. I get a Location out in the sea outside Africa, the accuracy is around 2000. My Google Maps is showing the accurate position.
Does anyone have a idea about what the problem can be? It is the same when I use the getLastKnownLocation().
The network location provider is extremely inaccurate. Usually if you are connected to WiFi, you can get within 100 meters, but on cell towers, 2000 meters is pretty normal. There's not really a problem, persay.
If Google Maps is able to get an accurate location with GPS turned off, then it is likely due to some very advanced location management that they do. But 2000 meters with Network Location, unfortunately, is normal in all of my test cases.
EDIT:
It is to say that the value of location.getAccuracy() is around 2000 (not a value in meters).
When getAccuracy() returns a value of 2000, it means meters. Here's what The Docs say about getAccuracy():
Returns the accuracy of the fix in meters. If hasAccuracy() is false, 0.0 is returned.
But it returns a float value, and while it doesn't display the unit, it is still meters.

Categories

Resources