Android disable screen timeout while app is running
You want to use something like this:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Android prevent screen timeout
Solution was very simple done using Unity adding the following Code into the Start() Function:
Screen.sleepTimeout = SleepTimeout.NeverSleep;
I doesn't know if it is switched of automatically by Unity or nor but I hope so.
Link to Unity Documentation
Programmatically disable screen timeout
Do you just want the screen to time out after you've closed your application? Or is something inside your application going to reset the screen timeout so that it will happen even while your app is running?
If the former I don't think you need to do anything, when you're app is stopped the screen timeout will return to normal.
If the latter it seems like the snippet you've provided would do the trick. But I have no experience with it so I couldn't be certain.
How to prevent the screen of an android device to turn off during the execution of an Activity?
Add android:keepScreenOn="true"
to some widget in your layout XML resource for this activity. So long as that widget is visible on the screen, the screen will not turn off automatically.
EDIT:
A WakeLock
, as suggested by other answers, technically will work. But then you have to manually release the WakeLock
(if you mess that up, the screen will stay on a long time). And, since you could mess it up, you need the WAKE_LOCK
permission. Using keepScreenOn
avoids all of that.
Kivy disable screen timeout
Looking further, I found the solution.
I thought not to delete the question, maybe someone else is facing this.
Solution:
edit buildozer.spec and set
android.wakelock = True
Related Topics
How to Create Custom Shape Button with Selector in Android
Out of Memory Exception Due to Large Bitmap Size
How to Display Gif in React-Native Android App
Creating Different Layout for Android Phone and Tablet
Google Play Services Out of Date. Requires 11011000 But Found 10289574
Android Datepickerdialog: Set Min and Max Date for Selection
Scrolling Edittext Inside Scrollview
Ask for Password Before Uninstalling Application
Writing Text File to Sd Card Fails
Firebase Sort by Points Depending on Date
Android Marshmallow: Changing Permissions at Run Time Crashes App
How to Create and Save a Screenshot from a Surfaceview
Room - Livedata Observer Does Not Trigger When Database Is Updated
Fragment Inner Class Should Be Static