Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the interval of LocationRequest

I set my application to get location notification every 5 seconds.

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(5000);
    mLocationRequest.setFastestInterval(5000/6);
    myLocationReq.requestLocationUpdates(mLocationRequest

so - every 5 seconds, onLocationChanged is being called. This is working fine.

Now I want to change the interval to be 1 second, without calling

     requestLocationUpdates

How can this be done?

like image 562
DuduArbel Avatar asked May 02 '14 07:05

DuduArbel


Video Answer


1 Answers

Hope this answer isn't too late, but simply create a LocationRequest object, with the desired setInterval value. And then just call requestLocationUpdates with it.

I used this with tabs where 1 tab had to get location updates faster than the others. So I just changed the interval in the onResume and onPause methods.

like image 174
Fanta1090 Avatar answered Nov 02 '22 14:11

Fanta1090