I was looking to implement a whatsapp like pop-up in my project and i succesfully implemeted it by using 'Dialogue as Activity'. Below code is the one which helps to turn on the screen and show the pop-up while the phone is in sleep mode.
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
);
but it keep staying in the "screen on" mode after that. I couldn't find any method for "turning screen off".
Do anybody know a way to solve this issue ?
When you no more need to keep the screen on, simply remove the flags that keep your screen on
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);