开发者

Calling onLocationChanged() function on Android

I am using locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); in Android.

If I set minimum time = 120000 and distance = 10000, if user moves 11000 meter in 60000 millisecond, then location change开发者_JAVA技巧d function will execute or not?

I want to know then when the onLocationChanged() function is called.

Maybe something like:

  • If time = 120000 and distance = 10000 then execute (...)

or:

  • or time = 120000 or distance = 10000 then execute (...)


the minTime is used get the updates (this is why they recommend you set it above 60000ms)

Background services should be careful about setting a sufficiently high minTime so that the device doesn't consume too much power by keeping the GPS or wireless radios on all the time. In particular, values under 60000ms are not recommended.

The actual handler is also called when either

  1. minTime has passed since last Update
  2. LocationProvider has moved greater than minDistance from last update

The reason the minTime is there is for background application to not eat all the battery.

LocationManager Reference


whichever is first comes than location changed called, if distance is not complete and time going than location changed called or time is not going but distance has gone than called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜