Android的位置提供商 - GPS或网络服务提供商? [英] Android Location Providers - GPS or Network Provider?

查看:245
本文介绍了Android的位置提供商 - GPS或网络服务提供商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想确定用户的当前位置。然而,我有一对夫妇在这方面的问题:

  1. 有不同的位置提供,哪一个是最准确的?该 GPS提供商或<一href="http://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER">Network提供商?

  2. 在做那些可以提供不同多远?他们如何发挥作用?

  3. 能否请您为我提供关于如何开始与执行在我的应用GPS功能有些code-片段或教程?

解决方案
  

有3个位置提供的Andr​​oid系统。

     

它们是:

     

GPS - >(GPS,AGPS):命名。本   供应商决定采用卫星位置。取决于   情况下,该供应商可能需要一段时间才能返回位置锁定。   需要许可android.permission.ACCESS_FINE_LOCATION。

     

网络 - >(AGPS,小区ID,无线网络MACID):网络名称   位置提供。此提供程序确定位置的基础上   可用性的手机信号塔和WiFi接入点。结果   通过网络查找的手段检索。要求的任一   权限android.permission.ACCESS_COARSE_LOCATION或   android.permission.ACCESS_FINE_LOCATION。

     

被动式 - >(小区ID,无线MACID)::一种特殊的地理位置提供商   接收位置,而无需实际启动位置锁定。本   提供商可用于其它时被动地接收位置更新   应用程序或服务要求他们没有实际要求   自己的位置。该供应商将返回所产生的位置   其他供应商。需要许可   android.permission.ACCESS_FINE_LOCATION,虽然如果GPS是不   启用该供应商可能只返回粗糙的修补程序。这是什么   Android把这些位置提供,但是,基本   技术,使这个​​东西工作被映射到特定的一组   硬件和提供电信能力(网络服务)。

     

最好的办法是先用网络或被动供应商,   然后回退中的全球定位系统,并根据不同的任务,切换   供应商。这包括所有的情况,并提供了最低的共同   分母服务(在最坏的情况下)和一流的服务(以最好的   情况)。

文章参考: Android的位置提供商 - 全球定位系统,网络,无源由费尔南多·塞哈斯

code参考: http://stackoverflow.com/a/3145655/28557

-----------------------更新-------------------- ---

现在的Andr​​oid有电熔位置提供

融合的地点提供智能管理的基本定位技术,让您根据您的需要的最佳位置。它简化途径的应用程序来获取用户当前位置有更高的精度和更低的功耗使用

电熔位置提供者提供了三种方式来获取位置

  1. 最后位置:当你想知道当前位置一度使用
  2. 使用监听器请求位置:使用时,应用程序在屏幕上/前端,并要求继续位置
  3. 请求位置使用待定意向:使用应用程序时,在后台,并要求继续位置

参考文献:

官方网站:<一href="http://developer.android.com/google/play-services/location.html">http://developer.android.com/google/play-services/location.html

电熔位置提供例如:<一href="http://www.kpbird.com/2013/06/fused-location-provider-example.html">http://www.kpbird.com/2013/06/fused-location-provider-example.html GIT:<一href="https://github.com/kpbird/fused-location-provider-example">https://github.com/kpbird/fused-location-provider-example

<一个href="http://blog.lemberg.co.uk/fused-location-provider">http://blog.lemberg.co.uk/fused-location-provider

-------------------------------------------- ------------

In my application I would like to determine the user's current location. I do however have a couple of questions in this regard:

  1. There are different Location Providers, which one is the most accurate? The GPS Provider or the Network Provider?

  2. In how far do those available provider differ? How do they function?

  3. Could you please provide me with some code-snippets or tutorials on how to get started with implementing GPS functionality in my application?

解决方案

There are 3 location providers in Android.

They are:

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).

Article Reference : Android Location Providers - gps, network, passive By Fernando Cejas

Code Reference : http://stackoverflow.com/a/3145655/28557

-----------------------Update-----------------------

Now Android have Fused location provider

The Fused Location Provider intelligently manages the underlying location technology and gives you the best location according to your needs. It simplifies ways for apps to get the user’s current location with improved accuracy and lower power usage

Fused location provider provide three ways to fetch location

  1. Last Location: Use when you want to know current location once.
  2. Request Location using Listener: Use when application is on screen / frontend and require continues location.
  3. Request Location using Pending Intent: Use when application in background and require continues location.

References :

Official site : http://developer.android.com/google/play-services/location.html

Fused location provider example : http://www.kpbird.com/2013/06/fused-location-provider-example.html GIT : https://github.com/kpbird/fused-location-provider-example

http://blog.lemberg.co.uk/fused-location-provider

--------------------------------------------------------

这篇关于Android的位置提供商 - GPS或网络服务提供商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆