android - 为什么 `PRIORITY_BALANCED_POWER_ACCURACY` 比 `PRIORITY_HIGH_ACCURACY` 消耗更多电池?

标签 android gps

我们对同一情况下仅连接到 WiFi 的设备每 10 分钟请求位置所消耗的电池电量进行了基准测试

  • 恢复出厂设置
  • 相同的起始电池电量
  • 没有安装额外的应用

首先将优先级设置为 PRIORITY_BALANCED_POWER_ACCURACY,然后设置为 PRIORITY_HIGH_ACCURACY

令人惊讶的是,前者与后者耗电量相同,甚至更多。这是电池使用情况的图表:

有人可以解释一下这种行为吗?

最佳答案

PRIORITY_HIGH_ACCURACY 更有可能使用 GPS,PRIORITY_BALANCED_POWER_ACCURACY 更有可能使用 WIFI 和手机信号塔定位。

  • PRIORITY_BALANCED_POWER_ACCURACY(~100 米“方 block ”精度)
  • PRIORITY_HIGH_ACCURACY(以电池生命周期为代价尽可能准确)

    使用setInterval(long)setFastestInterval(long) 来节省电池生命周期。

Example:

private static final long INTERVAL = 60 * 1000;
private static final long FASTEST_INTERVAL = 5 * 1000;
private static final long DISPLACEMENT = 100;

private LocationRequest createLocationRequest(){
        LocationRequest mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(INTERVAL);
        mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        mLocationRequest.setSmallestDisplacement(DISPLACEMENT);
        return mLocationRequest;
    }

Google 在此处描述了 LocationRequest 类:http://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html

关于android - 为什么 `PRIORITY_BALANCED_POWER_ACCURACY` 比 `PRIORITY_HIGH_ACCURACY` 消耗更多电池?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31119580/

相关文章:

android - 如何从数据库获取项目的值并将其设置为微调器值

android - cpu-features.h 没有这样的文件或目录 webrtc Android 构建

iOS : Check the Coordinate using GPS

android - 使用 Google Play 服务中的设置 API 启用 "High Accuracy"位置

android - 透明Activity独立开启

android - 在此处创建 API Android 请求 ID?

android NotificationManagerCompat.areNotificationsEnabled 不工作

Android 模拟器无法识别 GPS 已启用

用于位置的 Android 前台服务

android - 使用 DDMS 模拟器控件将欺骗位置发送到平板电脑 android 设备