Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android disable screen saver

I'd like to disable screen saver while my appliction is running. How it can be done? Where is the best place to disable / enable the screen saver? in the first activity? in the application.java?

like image 344
eyal Avatar asked Jun 09 '11 08:06

eyal


People also ask

How do you turn off screensaver on Samsung?

Go to settings, then display, then scroll up to screen saver and tap it and select the option which says none. Hope this helped!

How do I turn off screensaver lock?

Expand Control Panel, and then click Display. In the right pane, double-click Password protect the screen saver. Select Disable on the Policy tab.

How do I turn on screensaver on Android?

Turning on the screensaver is very simple. Open up Settings then tap on Display. Scroll down through the menu until you find Screensaver or Daydream (depending on which version of Android you're currently running). Tap on the button to the right of the name and this will enable the feature.


2 Answers

The wake lock permission must be specified in the manifest.

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

Then in the activity use the following to keep the screen on while the activity is running.

getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);

Remember that unnecessarily keeping the screen on unnecessarily drains power from the user's device.

like image 176
Programmer Bruce Avatar answered Oct 29 '22 08:10

Programmer Bruce


You must also add:

import android.view.WindowManager.LayoutParams;

like image 34
user2976482 Avatar answered Oct 29 '22 09:10

user2976482