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);
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.