android.location.LocationManager.PASSIVE_PROVIDER是什么意思? [英] What is the meaning of android.location.LocationManager.PASSIVE_PROVIDER?

查看:887
本文介绍了android.location.LocationManager.PASSIVE_PROVIDER是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解 GPS_PROVIDER 的含义(位置来自GPS信号)和 NETWORK_PROVIDER (位置取决于基站和无线访问点),但我不理解 PASSIVE_PROVIDER ,尽管API中有定义:

一个特殊的位置提供者 没有实际接收位置 启动位置修复.这 提供者可以用来被动地 当其他人收到位置更新时 应用程序或服务要求他们 而不实际要求 自己定位.该提供者将 返回其他人生成的位置 提供者.您可以查询 使用getProvider()方法确定 位置更新的来源. 需要许可 android.permission.ACCESS_FINE_LOCATION, 虽然如果未启用GPS 这个提供者可能只会返回粗糙 修复.

为什么一个人会使用它而不是其他提供者中的一个?为了节省电池寿命?被动提供程序是否仅在某些其他应用程序显式请求真实提供程序的数据时才返回有用信息,还是从该位置请求位置始终安全?

此提供程序对于与用户位置配合使用但又不想浪费电池寿命的服务很有用.

例如,谷歌纵横将您的当前位置发送到网络服务,以让您的朋友知道您的位置.如果此服务每5分钟请求一次GPS修复,则设备电池将很快耗尽.如果该服务请求被动位置提供者,则每次启动Google地图时将发送位置,并且需要获取修复程序或其他一些应用程序来启动位置提供者更新,并且该服务可以对位置数据进行操作,而无需花费额外的精力进行位置更新.

如果您需要在正确的时间正确使用位置数据,则使用此提供程序将无济于事.对于大多数未在后台服务中运行的事物,此位置提供程序毫无用处,因为它仅在其他应用触发用户位置更新时才会发送更新.

I understand the meaning of GPS_PROVIDER (locations come from GPS signals) and NETWORK_PROVIDER (locations are determined from cell towers and wireless access points), but I don't understand the meaning of PASSIVE_PROVIDER, despite the definition in the API:

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. You can query the getProvider() method to determine the origin of the location update. Requires the permission android.permission.ACCESS_FINE_LOCATION, although if the GPS is not enabled this provider might only return coarse fixes.

Why would one use this instead of one of the other providers? To save battery life? Does the passive provider only return useful information if some other app explicitly requests data from the real providers, or is it always safe to request locations from this?

解决方案

This provider is useful for services that work with the users location but don't want to waste battery life as you pointed out.

For example Google Latitude sends your current location to a web service to let your friends know where you are. If this service would request a GPS fix every 5 minutes the device battery will be empty very fast. If the service requests a passive location provider a location is send every time Google maps is started and a fix aquired or some other apps initiates a location provider update and the service can act on location data without spending additional power on the location updates.

If you need correct location data at an exact moment using this provider won't help. For most things that are not running in a background service this location provider is useless because it will only send updates if other apps trigger an update of the user location.

这篇关于android.location.LocationManager.PASSIVE_PROVIDER是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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