java - Wakelock - 标记名称应使用唯一前缀后跟冒号

标签 java android

Screenshot of code in Android Studio

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 thePowerManager 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/

相关文章:

java - 我在对象中收到 json 响应,但我想在 Json 数组中

android - 适用于openCV应用程序的基于Android Windows的模拟器?

java - 死代码从何而来?

java - 包结构影响托管类

java - 除法时任意位数的小数

android - Zxing条码扫描器代码

java - 如何在所有 Android 版本中以编程方式获取当前 CPU 温度?

android - Intent 在服务中一直为 Null

java - IntelliJ IDEA - 错误 : A JNI error has occurred, 请检查您的安装并重试

Java 的 Scanner 类 : using left- and right buttons with Bash