LocationManager每分钟更新,消耗了大量的电池电量 [英] LocationManager updates every minute, consuming a lot of battery power

查看:120
本文介绍了LocationManager每分钟更新,消耗了大量的电池电量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些code类似以下内容:

I've got some code similar to the following:

LocationManager m = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
Criteria c = new Criteria();
c.setAccuracy(Criteria.ACCURACY_COARSE);
String provider = m.getBestProvider(c, true);
Intent i = new Intent(context, LocationReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);

m.requestLocationUpdates(provider, 900000, 0, pi);

下面是接收器清单条目:

Here is the manifest entry for the receiver:

<receiver android:name=".LocationReceiver" />

它的大部分工作正常,并更新每15分钟的时间。但有时,它每分钟更新,并消耗了一堆电池电量。我在做什么错在这里?

Most of the time it works fine, and updates every 15 minutes. Sometimes, however, it updates every minute, and consumes a bunch of battery power. What am I doing wrong here?

编辑:是的LocationManager并不意味着这样使用的后台操作

Is the LocationManager not meant to be used like this for background operations?

推荐答案

我使用的技巧回答此处的持续监控地点最好的办法

I used the technique answered here: Best way to constantly monitor location

这篇关于LocationManager每分钟更新,消耗了大量的电池电量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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