Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling screen sleep Programmatically in Android?

Tags:

android

Can you please tell me how to prevent the Android Activity from sleep mode programmatically. Or can we declare something related to this in Android Manifest file.

like image 206
Nikki Avatar asked Nov 24 '10 05:11

Nikki


People also ask

How do I prevent an Android device from going to sleep programmatically?

Using android:keepScreenOn="true" is equivalent to using FLAG_KEEP_SCREEN_ON . You can use whichever approach is best for your app. The advantage of setting the flag programmatically in your activity is that it gives you the option of programmatically clearing the flag later and thereby allowing the screen to turn off.

How do I keep my Android screen awake?

Enable stay awake mode To enable the "Stay Awake" mode, navigate to the tablet's Settings. From the settings page navigate to > About Tablet > Software Information. Then tap the "Build Number" 7 times to enable developer mode. Developers mode is where you'll find the Stay Awake option, toggle to enable.

What is the use of Wakelock in Android?

A wakelock is a powerful concept in Android that allows the developer to modify the default power state of their device. The danger of using a wakelock in an application is that it will reduce the battery life of a device.


1 Answers

setKeepScreenOn(true)

like image 130
techiServices Avatar answered Oct 12 '22 20:10

techiServices