是位置提供一个真正的电池耗尽? [英] Is location provider really a battery drain?

查看:187
本文介绍了是位置提供一个真正的电池耗尽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现基于位置的服务。我不需要精确的位置信息,所以没有GPS是必要的。

I need to implement location-based service. I don't need fine location, so no GPS is needed.

最简单的办法是开始监听位置在应用程序启动的更新,使其保持开机状态:

Easiest would be to start listening for locations updates at app start, and leave it ON:

    mLocationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 100, mPendingIntent);

因为我并不需要太多的准确性,我设置的更新频率最大,为10秒,和100米,而不是默认的0,0。

Since I don't need much accuracy, I set max frequency of updates, to 10s, and 100m instead of default 0, 0.

当我们想到的位置,我们认为电池耗尽,但我想这是一个捷径,只有GPS真正消耗电池电量。我认为这种利用网络提供商不会耗尽电池。有什么想法?

When we think location, we think battery drain, but I guess this is a shortcut and that only GPS really drains the battery. I think that such a use of network provider wouldn't drain the battery. Any thoughts?

推荐答案

您百米距离滤波器将无助于你从电池消耗的角度来看。这将只能控制多少次你的 PendingIntent 被因修正执行。

Your 100m distance filter will do little for you from a battery drain standpoint. That will only control how many times your PendingIntent gets executed due to fixes.

您10秒时间值的也许的使用由操作系统来控制用电量,但也不能保证。和,用一个值的低,似乎不大可能,它将被使用。每隔一小时,可能,但不是每10秒

Your 10 second time value might be used by the OS to control power usage, but there is no guarantee. And, with that low of a value, it seems highly unlikely that it would be used. Every hour, maybe, but not every 10 seconds.

更大的事情是,你将需要保持在CPU供电上所有的时间。而且,由于您使用的是 PendingIntent 的味道 requestLocationUpdates(),我猜测你打算收集数据很长一段时间。

The bigger thing is that you will be needing to keep the CPU powered on all the time. And, since you're using the PendingIntent flavor of requestLocationUpdates(), I am guessing that you plan on collecting data for a long time.

如果你只有权限,安卓有望避开了WiFi热点接近检测,这将节省一点力量。

If you only have COARSE permission, Android hopefully eschews the WiFi hotspot proximity detection, which will save a bit of power.

从总体上看,网络供应商将消耗更少的功率比将GPS​​的供应商。 少是相距甚远的小。在一台Nexus级的Andr​​oid设备,GPS + CPU给了我几个小时的电池续航时间(通过使用谷歌导航确定)。我希望网络运营商+ CPU持续了几个小时时间,但仅此而已,因为CPU是在自己的权利相当显著电池消耗。

On the whole, the network provider will consume less power than will the GPS provider. "Less" is a far cry from "little". On a Nexus-class Android device, GPS + CPU gives me a few hours battery life (as determined by using Google Navigation). I would expect network provider + CPU to last a few hours longer, but that's about it, because the CPU is a fairly significant battery drain in its own right.

我更大的担忧是:

最简单的办法是开始监听位置在应用程序启动的更新,并把它留在

Easiest would be to start listening for locations updates at app start, and leave it ON

这听起来像是你实际上并没有打算删除你的位置更新。这是一个非常糟糕的主意,与任何类型的供应商(除的也许的被动提供者)。请有当你注册和删除更新一个更具体的计划。特别是,要确保的用户的都有,当你消耗电池到这种程度的控制能力。

This sounds like you aren't actually planning on removing your location updates. This is a really bad idea, with any sort of provider (except maybe the passive provider). Please have a more concrete plan for when you are registering and removing the updates. In particular, make sure the user has the ability to control when you are consuming battery to this degree.

这篇关于是位置提供一个真正的电池耗尽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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