Prevent screen form going black on android


Is there an existing solution on how to prevent the screen from going black on android? I found this thread, but the links do not work anymore:


Looks like there’s some details here:

I’d love suggestions on where/how we support something like this in the Lime API

You shouldn’t use wakelock just to keep screen on, also lime already has code that prevents auto-lock:

    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

In my games developed for android on java I simply use android:keepScreenOn="true" in layout, which is equal to WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON

Do I understand correctly? Lime is already taking care of it? But my screen IS going black after about half a minute.
Do I have to enable this somehow?

It seems that it is only in legacy code, so 1) you must use -Dlegacy, 2) fullscreen=“true” must be set for window and 3) ANDROID_TARGET_SDK_VERSION should be less than 19

If it didn’t help, please show me what is under export/android/bin/src/org/haxe/lime/

            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

That’s strange, both FLAG_FULLSCREEN and FLAG_KEEP_SCREEN_ON is available even on API 22. @singmajesty What do you think about it?

Thanks, for now it is fixed for me. I have edited the file in my lime install to add the flag even if the SDK version is above >19.

This must have been related to a change in order to handle Android fullscreen without showing the on-screen buttons, FLAG_KEEP_SCREEN_ON was an unfortunate casualty, but perhaps we should use an AndroidManifest.xml way of doing this (straight up single option) or go completely the route of making this a runtime configurable option