我有一些类似于以下的代码:
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);
这是接收者的清单条目:
<receiver android:name=".LocationReceiver" />
大多数时候它运行良好,并且每 15 分钟更新一次。然而,有时它每分钟更新一次,并消耗大量电池电量。我在这里做错了什么?
编辑:LocationManager 不应该像这样用于后台操作吗?
我使用了这里回答的技术:持续监控位置的最佳方法 https://stackoverflow.com/questions/5849197/best-way-to-constantly-monitor-location
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)