getLastKnownLocation vs requestLocationUpdates

吃可爱长大的小学妹 提交于 2019-12-11 03:45:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!