[Superpost] Possible to keep screen active / screen on?

I am incorporating a timer into an app and would like to keep the screen on even if the user has auto lock enabled. I know this is possible with extensions in Classic, but is it possible in cross platform version? Thanks.

Bump! Anyone know how to make this happen?

Hey @Kyle_Williams and @Arun_Nijhawan - this isn’t an option in Thunkable X right now unfortunately.

@Arun_Nijhawan, what use do you have in mind?

1 Like

The reason you cant do this in X is because you cannot activate a click or simulate a user interaction on the screen.

There are a few things you can try to do to keep the screen alive, by creating a loop and changing a small area of the screen visible and invisible, and make the background colour the same as the screen.

However that only registers as a screen change, and not as a user interaction. The other problem with that is that you cannot break out of that loop with a button press, so you need to nest your entire program on that screen within a loop that every 5 minutes would go through.

It might work for you based on your program needs.

1 Like

Just seeing this! I’m hoping to keep a sound file playing. Currently, if the screen goes off, the sound stops.

I should’ve specified, if there’s a way to keep the sound going while the screen goes off, that would work!

Hello everyone;

I’m new to programming with Thunkable X recently, having worked with App Inventor before! I switched to Thunkable, because I can also programing for IOs here.
My question to the Comunitiy:
How can I keep the screen active in Thunkable so that the phone does not switch to stand by mode?
With APP Inventor I could prevent this with a “Notifiler block”. I have attached the blocks :wink:

Notifiler

Does anyone have a solution for me?

Also I searched around in the search function and in the Comunitie, in the meantime there is already a solution how I can insert Extensions in Thunkable X Cross Version!
Or is there a way of the Thunkable Classic platform to import the developed apps into the cross platform?

Thank you already for your help
Michael

Hi there,
What means “Screen active”? Is there means does not close the screen ever until have action? Have any example to let me understand more?
Thanks. :slight_smile:

Hi;

I mean that normally the screen - the phone goes into sleep mode. Usually after about 30 seconds. And I do not want that. I want the phone to stay “active”. The reason is that via my app every 3 seconds GPS data are sent to a webside. However, if the phone goes into sleep mode, this transfer will be interrupted. Therefore, as mentioned, it should always stay active when my app is activated!
I hope I could express myself clearly and understandably?

Michael

In android you can set it in the phone options, but it keeps the whole phone screen active so it’srisky to use it you forget to disableit.
Not sure if it can be set to work only for certain apps, but there may be an app that does that.

Hi;
I have obviously misrepresented myself, with my bad english. I just want that, when my app is active, it does not go into sleep mode - stand by mode. If my app is disabled, should / must the mobile phone again, as always and normally go in to the sleep mode.

Michael

Michael,

I am afraid that we do not currently support that functionality. Please feel free to add a feature request here in our external issues list.

-Mark

1 Like

Keep the screen active by looping webview with a video asset… can someone else help me spread this trick around? Thunkable Staff?

I’m not sure we can recommend/endorse this method - my guess is that it might be very draining on users batteries.

Have you filled in the feature request form that Mark linked to @hhuman?

Of course it’s more draining on batteries when the screen is on then when it is off. You can limit it to a 1 hr low res soundless .mp4 file which is about 4mb… and then it won’t need to loop. This will help in the cases where some devices only allow only 30 mins max to keep the display on. You don’t want to keep it going and going until the device dies, unless you keep it plugged in… anything is positive.

You can try embedding a webviewer containing a site with NoSleep.js included. You can change the webviewer to height 0 and it will usually still work. You can give it a try with the sample app I created:

https://x.thunkable.com/copy/4957325fda75aa64718fd3c7e6be3ec7

Be aware that you need to enable AllowsInlineMediaPlayback for it to work without interrupting your screen. Also I cannot guarantee if Apple or Google will approve an app containing an invisible webview.

Best, Chris

4 Likes

Hey Shark, thanks for this. It was exactly what I was looking for in my app! How do I include NoSleep.js in a site? Can I do this with the site as an asset?

1 Like

there should be instructions how to embed this at the github repo. However there are several known problems with offline html files in Android right now and I don’t think that they currently work at all…

1 Like

I am trying this method and the offline html file is loading right in the webviewer… when I click the toggle button in the app (live and downloaded) to enable the wake lock, it doesn’t work though. I tried changing the path of the js file in the html to “./NoSleep.min.js” and “//NoSleep.min.js” and “/NoSleep.min.js”… doesn’t make a difference. How else might I try to accomplish this? What is the InjectedJavaScript function of webviewer?

Wait, I don’t know what happened… I just typed the name of the js file… into the InjectedJavaScript part of the Webviewer settings and the javascript showed up in the webviewer so I deleted it. The html file returned and now when I click the enable button, it works!!!

1 Like

Glad it worked out for you :slight_smile:

Did you test it on iOS and Android? Because in the built app I had problems that Android would not display my local html files and there are known issues :grimacing: I guess you included an html file as well as the js, right?

1 Like