How can I turn off my android SmartPhone screen programmatically?
I tried with the code below, it doesn't work, it just locks the screen but does not "switch off" the screen.
The method goToSleep have been Removed. https://developer.android.com/sdk/api_diff/21/changes/android.os.PowerManager.html
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
wl.acquire();
..screen will stay on during this section..
wl.release();