2

What I am trying to do

  • Get users location at specified interval using a Service so that as long as application is running Location can be retrieved

Problem I am facing

  • Even if I am in same location for long time, each time the Latitude , Longitude changes with different Accuracy levels
  • Due to this, even if user has not changed his location, if I am plotting the Location in GoogleMap it makes jump to very near by places being my zoom level 18.0f
  • mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLon, 18.0f));

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

Community
  • 1
  • 1
Sreehari
  • 5,621
  • 2
  • 25
  • 59

2 Answers2

5

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.
TDG
  • 5,909
  • 3
  • 30
  • 51
0

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/

Jagjit Singh
  • 1,909
  • 1
  • 14
  • 19
  • 1
    Last link which I tried is using the same . Anyways thanks for the suggestion.. https://github.com/nickfox/GpsTracker/blob/master/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LocationService.java – Sreehari Mar 02 '16 at 12:41
  • @Stallion Welcome :) It is requesting location for every 1 sec and there is no distance limit – Jagjit Singh Mar 02 '16 at 12:49
  • I have tried these, locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,10, 10, mLocListener); and locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,10,10, mLocListener); also, Still the same results I am getting – Sreehari Mar 02 '16 at 13:12
  • @Stallion ok i will try and if found something i will post – Jagjit Singh Mar 02 '16 at 13:22
  • That should be great.Thanks – Sreehari Mar 02 '16 at 13:46