问题
I have confusion in this parameter
locationManager.requestLocationUpdates(provider,
60000,
10,
listener);
So here is how it executes location update listener
.
if time = 60000 AND distance = 10
then it will execute or
if time = 60000 OR distance = 10
then it will execute.
Please help me to come out this confusion.
回答1:
According to the docs :
The elapsed time between location updates will never be less than
minTime
So minTime
takes precedence. Further on it says :
The minDistance parameter can also be used to control the frequency of location updates. If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed
So it should be if(time >= minTime AND dist >= minDistance)
, meaning won't check distance if too early. BUT don't take those parameters too seriously before JellyBeans.
回答2:
As per my understanding it should be OR
. Read this blog for more info.
Keep in mind that GPS has an accuracy of 10 to 50 meters itself.
回答3:
In this method second parameter 60000 show the time for update the of the location in millisecond so 60000 means 60 second (60*1000). 'OR' The third parameter is the distance(minimum distance interval for update the location) in your case it is 10- mete
I hope this is help.
来源:https://stackoverflow.com/questions/6302175/requestlocationupdates-parameter-android