How to avoid frequent location updates?

I am new to android. I want to get GPS coordinates at intervals of 3 minutes, but I get location updates every second.

How can I avoid this?

Please suggest something. I am using the following code:

captureFrequencey=3*60*1000;    
LocationMngr.requestLocationUpdates(
    LocationManager.GPS_PROVIDER, captureFrequencey, 0, this);
+5
source share
4 answers
LocationMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, captureFrequencey, 0, this);

This is because you have set the minimum distance to 0. Change it to 100 meters and check!

LocationMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, captureFrequencey, 100, this);


Refer to the documentation .

+3
source

Lazy Ninja has already given you a solution.
But you should understand that when you call the location update request, it checks the conditions min time and min dist, and if someone is right, he catches the location. In your code

LocationMngr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 
                                                captureFrequencey, 0, this);

0 , . , .
, .

+2

See location strategies in docs

0
source

Just quickly add the correct answers ... setting the time and distance of the update will not work the same on all devices.

These options are treated as “hints” to the location provider.

Therefore, although it is good practice, some devices may not always fulfill these exact values.

0
source

All Articles