Sreehari
Sreehari

Reputation: 5655

Location from GPS_PROVIDER or NETWORK_PROVIDER in android is not consistent

What I am trying to do

Problem I am facing

I have tried approaches mentioned in stackoverflow Link One and stackoverflow Link Two

But even though I am sitting in the same location and retrieving location in regular interval, the Lat and Lon differs like this , see the highlighted values at end of every lat lon:

Latitude: 12.8379283 Long: Longitude: 77.6647266

Latitude: 12.8379233 Long: Longitude: 77.6647368

Latitude: 12.8379285 Long: Longitude: 77.6647506

Latitude: 12.8379245 Long: Longitude: 77.6647546

but still every time the Accuracy differs and Lat Lon slightly changes.

As my code trials are exactly same as mentioned in link's I am not just copy pasting here. How can this be resolved

Upvotes: 2

Views: 1550

Answers (2)

TDG
TDG

Reputation: 6151

The accuracy of the GPS is not absolute, so even a static device will show different locations in successive readings. Try the following:

  1. You can add a method that detects if the mobile is static or not, by reading he accelerometer - if the delta between two readings is bigger than some threshold - the device is moving. If it's too small - it's not moving. To determine the delta - put the device on a table and see what values you get.
  2. Ignore close readings - Take the first reading with good accuracy (<20m or other value you determine) and use it as a reference - if the next reading gives a very small distance, close to the reference (<10m or other value), ignore it. If it's bigger - set it as the new reference.

Upvotes: 5

Jagjit Singh
Jagjit Singh

Reputation: 1969

try to set Accuracy_HIGH and set time limit and distance limits.
try using google places fused api for location related work. Refer here: -http://coderzpassion.com/android-location-using-google-play-services/

Upvotes: 0

Related Questions