I'm using Android's LocationManager
and its method requestLocationUpdates
like this:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 10, this);
As I found out both the conditions of minTime and minDistance have to be met for location update, but I need to get update every 3 seconds or 10 meters.
I tried to put 2 requests like this:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 10, this);
but it doesn't work, I only get update every 10 meters with this code, not every 3 seconds.
I'm working with API19 if that matters.
The Documentation on requestLocationUpdate() says :
So you should be calling it like
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 10, this);
But If you set minTime to 0, it will be called once when it first receives a location update, then it won't be called until you change your position in minDistance meters.
Documentation Link for Reference
EDIT
As per the Discussion with @Matej I need to get update every 10 meters even if it happened in less than 3 seconds, and update every 3 seconds even if the location didn't change by more than 10 meters
If you want to regularly
requestLocationUpdates
, you should useTimer
andTimerTask
and haverequestLocationUpdates
run once every 3 seconds