Tag name should use a unique prefix followed by a colon (found tag). For instance
myapp:mywakelocktag
. This will help with debugging less... (Ctrl+F1)Wake Lock tags must follow the naming conventions defined in the
PowerManager
documentation. Issue id: InvalidWakeLockTag
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float distance = sensorEvent.values[0];
if (!isVideo && !isSpeaker) {
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (distance < 4) {
if (wlOn != null && wlOn.isHeld()) {
wlOn.release();
}
if (pm != null) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (wlOff == null)
wlOff = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");
if (!wlOff.isHeld()) wlOff.acquire();
}
}
} else {
if (wlOff != null && wlOff.isHeld()) {
wlOff.release();
}
if (pm != null) {
if (wlOn == null)
wlOn = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
if (!wlOn.isHeld()) wlOn.acquire();
}
}
}
}
最佳答案
将 "tag"
更改为 "AppName:tag"
它正在搜索字符串中的冒号“:
”。这不是一个非常明确的消息,我认为它是要我创建一个字符串变量并引用该变量。
关于java - Wakelock - 标记名称应使用唯一前缀后跟冒号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54004808/