问题
I want to send the most fresh and accurate location from my android app to the server every 5 min.
In this question I was advised to create an alarmManager which will register to LocationUpdates.
Why is this better than just calling getLastKnownLocation
and checking its accuracy?
回答1:
getLastKnownLocation will give you the last location fix from the network provider. It may not give the exact current location (see google documentation) LocationUpdates, on the other hand, will give the current location. you can implement it using locationClient. When the location is changed, OnLocationChanged(Location l) method is called which will provide you with most recent location. you can also set time after which location is updated.
来源:https://stackoverflow.com/questions/22575433/getlastknownlocation-vs-requestlocationupdates