在我的应用程序中,我想确定用户的当前位置.不过,在这方面,我确实有几个问题:
有不同的位置Provider ,哪一个最准确?GPS Provider号还是Network Provider号?
这些供应商之间的差异有多大?它们是如何运作的?
你能给我提供一些关于如何开始在我的应用程序中实现GPS功能的代码片段或教程吗?
在我的应用程序中,我想确定用户的当前位置.不过,在这方面,我确实有几个问题:
有不同的位置Provider ,哪一个最准确?GPS Provider号还是Network Provider号?
这些供应商之间的差异有多大?它们是如何运作的?
你能给我提供一些关于如何开始在我的应用程序中实现GPS功能的代码片段或教程吗?
There are 3 location providers in Android.个
它们是:
gps –> (GPS, AGPS): Name of the GPS location provider. This provider determines location using satellites. Depending on conditions, this provider may take a while to return a location fix. Requires the permission android.permission.ACCESS_FINE_LOCATION.
network –> (AGPS, CellID, WiFi MACID): Name of the network location provider. This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup. Requires either of the permissions android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION.
passive –> (CellID, WiFi MACID): A special location provider for receiving locations without actually initiating a location fix. This provider can be used to passively receive location updates when other applications or services request them without actually requesting the locations yourself. This provider will return locations generated by other providers. Requires the permission android.permission.ACCESS_FINE_LOCATION, although if the GPS is not enabled this provider might only return coarse fixes. This is what Android calls these location providers, however, the underlying technologies to make this stuff work is mapped to the specific set of hardware and telco provided capabilities (network service).
The best way is to use the “network” or “passive” provider first, and then fallback on “gps”, and depending on the task, switch between providers. This covers all cases, and provides a lowest common denominator service (in the worst case) and great service (in the best case).
文章参考:Android Location Providers - gps, network, passive By Nazmul Idris
代码参考:https://stackoverflow.com/a/3145655/28557
-----------------------Update-----------------------个
现在Android有Fused location provider个
融合位置Provider 智能管理底层定位技术,并根据您的需求为您提供最佳位置.它简化了应用程序获取用户当前位置的方式,提高了精确度并降低了功耗
融合位置提供程序提供三种获取位置的方式
References :个
官网:http://developer.android.com/google/play-services/location.html
融合位置Provider 示例: GIT:https://github.com/kpbird/fused-location-provider-example
http://blog.lemberg.co.uk/fused-location-provider
--------------------------------------------------------