How to get GPS coordinates every minute in Android?

I want to get my coordinates every minute, even if the user is not moving. Therefore, I used requestLocationUpdates with the following parameters:

  locMgr.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER,
                    60000,      // minTime in ms
                    0,      // minDistance in meters
                    PosljiLokacijo.this);

But when I test it on my HTC Hero (2.1 Android), and I don't move, onLocationChanged () is never called. If I change minDistance to 1, I get a few updates at the beginning, but after that they happen very irregularly.

How do I select these 2 parameters (minTime and minDistance) to get the coordinates every minute?

+3
source share
2 answers

, "minTime" "minDistance" , : . locationManager , . , , .

location ( , ) requestLocationUpdates.

. Timer, , :
http://developer.android.com/reference/java/util/Timer.html

, , .

+1

:

minTime . , .

, , , - minTime 0 . , , , .

+1

Source: https://habr.com/ru/post/1783419/


All Articles