Android Disable Screen Timeout While App Is Running

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



Leave a reply



Submit