Android Location Client的提供商 [英] Android Location Client's Provdier

查看:119
本文介绍了Android Location Client的提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用LocationClient和LocationRequest获取位置更新或当前位置.

I am able to get location update or current location using LocationClient and LocationRequest.

但是如何知道是使用gps提供程序还是网络提供程序来获取位置.

But how to know whether the location is obtained is using gps provider or network provider.

这是示例代码 https://developer.android.com/training/location/retrieve-current.html

推荐答案

显然,在使用LocationClientLocationRequest时不可能,因为优先级从源转移到获取location的需求/需求方面. .

Apparently it is not possible while using LocationClient and LocationRequest as the priority shifts from the source to the requirement/need side of obtaining the location.

提供者为融合位置提供者:

融合位置信息提供者
智能融合的位置提供者 管理基础定位技术,并为您提供最佳服务 根据您的需求定位.

Fused location provider
The Fused Location Provider intelligently manages the underlying location technology and gives you the best location according to your needs.

来源: Android位置API

即使他们从location对象中获取"了提供者",我还是试图在他们首次引入这些api时弄清楚这一点,
location.getProvider(),它返回:"fused"作为值,而不是GPS或NETWORK.

I tried to figure this out when they first introduced these api, even if you 'get' the 'provider' from the location object,
i.e. location.getProvider() , it returns :"fused" as the value and not as GPS or NETWORK.

如果您仍要推断出位置的来源,尽管并不完全准确,但是可以将其与通过

Still if you want to deduce the source of location, not entirely accurate, but it can be related to the PRIORITY that is set with the help of LocationRequest

示例:

公共静态最终诠释 PRIORITY_HIGH_ACCURACY

与setPriority(int)一起使用以请求最准确的位置 可用.

Used with setPriority(int) to request the most accurate locations available.

这将返回可用的最佳位置.

This will return the finest location available.

我观察到,根据LocationRequest设置的优先级,GPS的使用发生了变化.

I have observed that depending on the PRIORITY set with LocationRequest, the use of GPS is altered.

(对于 PRIORITY_HIGH_ACCURACY )应用是否使用GPS(并非专门用作其融合位置提供程序),因此对于其他两个PRIORITY设置,它智能地"管理融合源并尽可能精确地提供位置信息,从而节省电池/电量.

Only for PRIORITY_HIGH_ACCURACY does the app use GPS(not exclusively as its Fused Location Provider), hence for other two PRIORITY settings, it 'intelligently manages' the fused sources and provide the location with as much accuracy as possible, saving battery/power.

请注意:
当设置为PRIORITY_HIGH_ACCURACY时,我并不是说应该启用GPS来获取该条件下的位置,只是如果启用了GPS,您就可以直观地看到它在该PRIORITY下正在使用,而在您设置时并未使用不同的优先级.

Please Note:
When set to PRIORITY_HIGH_ACCURACY, i don't mean that the GPS should be enabled to obtain location under that condition, just that if GPS is enabled, you can visually see that it is being used under that PRIORITY and is not being used when you set a different PRIORITY.

融合位置提供程序使用GPS,WiFi,手机信号塔和传感器来确定准确的位置估算值.

  1. 看看基于位置API的Google IO ,这很好.

有用的演示文稿:Android位置

博客:2013年,但有用

这篇关于Android Location Client的提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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