How to turn off screen of android phone programmatically?

user3480011 picture user3480011 · Mar 31, 2014 · Viewed 7.2k times · Source

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

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

mWakeLock.acquire();

Answer