How to programmatically turn off the screen of an Android phone?

How to turn off the screen of an Android phone programmatically? I tried using the following code with no luck

PowerManager mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MYTAG");

mWakeLock.acquire();
+4
source share

Source: https://habr.com/ru/post/1534195/


All Articles