Android requestSingleUpdate vs requestLocationUpdates电池消耗

时间:2017-06-15 13:56:36

标签: android location locationmanager

我有一个应用程序,每分钟记录一次用户位置。直到今天我使用的是requestLocationUpdates():

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, gpsLocationListener)

每分钟(差不多)我收到一个更新并将其记录在onLocationChanged()方法中。 今天我发现requestSingleUpdate也可用:

locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, gpsLocationListener, null )

在第二种情况下,一旦我在onLocationChanged()中收到位置,我就会启动一个处理程序postDelay,一分钟后我再次运行requestSingleUpdate()。在没有请求位置更新的此分钟间隔期间,右上角的gps图标消失。

我的问题是:第二种解决方案可以减少电池消耗吗?谢谢

0 个答案:

没有答案