Are there any advantages of using FusedLocationProviderApi over LocationManager?

时光怂恿深爱的人放手 提交于 2019-11-30 11:31:45

FusedLocationProvider uses a mix of hardware to determine location based on the context of the request, meaning it's optimized transparently to you. It will also cache captured locations between applications to avoid unnecessary work to determine location info. So if a user has a variety of location-aware apps, they potentially avoid taxing the device (and waiting) for a location capture as one may have already been cached.

While the ol' LocationManager will suffice in small, one-off situations, you should definitely consider the newer alternative as the benefits may be great, and the work to implement, easy.

You may as well use it as Google Play Services is regularly updated across devices, and continuously includes improvements to location-based features (and more).

A link to an explanation of the FusedLocationProvider at launch: https://www.youtube.com/watch?v=Bte_GHuxUGc

In some situations FusedLocationProvider performs horribly. If you want to track your path on a map for example, it may decide to switch between GPS data and Wifi data. To calculate an accurate distance travelled, it is much better to force GPS readings with LocationManager, especially if you also want to track altitude, which wifi doesn't provide.

Pablo Baxter

Just keep in mind that FusedLocationProvider uses LocationManager under the covers to at least get GPS points. It may be performing Wifi scans and doing a look up on the results to determine location as well, instead of using the Network provider, but there isn't any documentation about this that I am aware of.

Unless you cannot or do not want to use FusedLocationProvider, I would recommend using it.

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