Chinaunix

标题: Android User Location。 [打印本页]

作者: jianyuehan    时间: 2011-12-23 03:25
标题: Android User Location。

一、两个重要的API类:
LocationManager,定位管理器类。
LocationProvider,定位方式提供者。

二、方式选择,老外写得很好:
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).

三、精度比较:(GPS精度最高,20米)
原文参考:http://stackoverflow.com/questions/6775257/what-must-i-use-gps-or-network-provider-for-my-location-in-android


作者:savant-pan, 微博 http://weibo.com/panxuewen,欢迎交指正、交流。






欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2