Breaking News
Home / Android / Android Snippets / How to keep screen from dimming or sleeping in Android?

How to keep screen from dimming or sleeping in Android?

In order for your application screen  need s to keep the screen from dimming or the processor from sleeping,  you must request this permission.

<uses-permission android:name=”android.permission.WAKE_LOCK” />

Specifically if you have a scenario where in Audio is being played using the MediaPlayer and you are invoking the MediaPlayer.setScreenOnWhilePlaying() or MediaPlayer.setWakeMode() methods, then you would have to request the permission in Android Manifest file else it would not work.

[pb_builder]

Check Also

How to check if an Android device can connect to Internet?

The following code snippet shows how to check if an Android device can connect to …

Advertisment ad adsense adlogger