Android Keep Screen On

My project is mostly comprised of matinees. My device “Display” is set to turn off after 15 seconds of inactivity.

The problem I have is that even though my matinee is playing the screen turns off after 15sec even though there is activity on the screen…

Is there a way to include a command in the android build which tells the device to keep the screen on while the application is running?

For now, I’ve downloaded the “Keep Screen On” app from the Google Play store and set my app to stay on but that’s not exactly what I want to force people to do to use my app.

Any advice or insight would be great

Thanks

Hi. I managed to get the screen working. You need to edit GameActivity.java file. It’s located in “Unreal Engine\4.5\Engine\Build\Android\Java\src\com\epicgames\ue4” and add this line AndroidThunkJava_KeepScreenOn(true); after “nativeResumeMainInit();”

I’ll give it a go. Thanks!

Works great!!! Thanks again.

Hi, is this still a valid method? I get an unknown error after packaging which disappears after I’ve removed this bit of code from the java file.
Thanks.

Hi, idk, probably not.

From Chris Babcock on the forums:

In Blueprint there is a “Control Screensaver” node. Add this with “Allow Screen Saver” checkbox off.
From code, use FPlatformMisc::ControlScreensaver(FPlatformMisc::EScreenSaverAction:isable).

Although there’s a comment there stating that it kills MoviePlayback on Android, I haven’t experienced problems (aside from seeking always jumping to 0 seconds, but that was already happening before).

1 Like

tried all of these and none work. phone going to sleep still. ive tried blueprint in game mode, in construct, begin play, everywhere. ive also tried adding the code AndroidThunkJava_KeepScreenOn(true);
i think ive put it in right place because it still compiles but maybe not… this holding me up major

bump. Did anyone had success with this? Sadly using this node does not work nor iOS, or Android:

1 Like

Yes this works. I use the node Control Screensaver Allow Screensaver to false, and now my screen keeps on. I put it in my character BP in begin play, so in main menu screen can off, but in gameplay where the character is used, it will not