本文介绍了帮助PROXIMITY_SCREEN_OFF_WAKE_LOCK Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启用了我的应用程序接近wakelock,并关闭屏幕时,接近传感器检测的东西。但是有一个问题,当屏幕被唤醒 - 它进入锁屏,而不是我的应用程序。发生这种情况而不管时间,该屏幕是关闭(即使传感器在几秒钟后清除)。这里的code我用:

I've enabled the proximity wakelock in my app, and it turns off the screen when the proximity sensor detects something. But there is a problem when the screen wakes back up -- it goes to the lockscreen, not my app. This happens regardless of the time that the screen was off (even if the sensor is cleared after a few seconds). Here's the code I used:

int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32;
mProximityWakeLock = pm.newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, LOG_TAG);
if(!mProximityWakeLock.isHeld()){
    mProximityWakeLock.acquire();
}

有没有什么办法来纠正这种行为?

Is there any way to correct that behavior?

推荐答案

您可以关闭锁屏,如果它不是一个安全的,使用:

You can dismiss the lock screen, if it is not a secure one, using:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

您可以从不断出现调用它的创立到prevent锁屏或者当您需要。我用它结合:

You can either call it on creation to prevent the lock screen from ever appearing or when you need to. I use it in combination with:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

似乎这并不干扰邻近锁

Which does not seem to interfere with the proximity lock.

这篇关于帮助PROXIMITY_SCREEN_OFF_WAKE_LOCK Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 19:02