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

Have you considered using an alert or similar to prompt your users to watch in full screen?

What sort of app are creating and how are you using video as part of it?

Of course if you have sleep mode at 30 mins, the screen will stay on for 30 mins, right?

Yes.

I agree with you. Many users are only able to dial a number on your phone.

I should service be better? It is a question of Philosophy. I know how to use 1% of the phones features, but if I need something that I can not be lazy and learn it. The user does not wish to think and wants to service has always been on the 100%? This can never be. The user can buy the iPhone 11, but if the user really does not think that such a phone and it will seem unfriendly.

I figured it out guys! Acetech, you gave me the solution except it wasnā€™t in this message thread, but another thread. It was a really simple straight forward method involving the webviewer and looping with video asset. So thank you for your generosity in sharing on here.

Domhall, Iā€™m making an app that reads Godā€™s words randomly. The video is to keep the screen on and the app running.

Hello!
Could you please also give us the link of the post with the solution?
Thank you!

Thank you! @hhuman :pray:

Youā€™re welcome! I went with this method instead for my appā€¦ check it out: Keep the screen active

Just amazing! :grinning:
Exactly what I was looking for!
Can you give me also a clue on how to get a trigger for this on a screen?
Thank you!

Iā€™ll share it in: Keep the screen active

Thank you very much!

1 Like

Hello.

I know that this topic was discussed in this post and in this post and they are marked as Solved, but for me it is not clear yet.

I know that @hhuman posted the solution but I was trying to workaround and to have the webpage / screen in the app activ as the user open the screen without any interaction.

So, the idea is to have the screen active as it opens.
I have removed the button for user interaction and I have the app screen full alive, without any enabling button, BUT it is not working if the user has the phone on Low Battery Modeā€¦
AS I use the version from @hhuman with the button that it is enabled by user, the screen stays alive even if the phone it is on Low Battery Mode.
WHY?

  1. Does anybody has idea how to make it to work even on Low Battery?
  2. Can somebody provide me a solution to have the enabling button under a Thunkable button?

Here is the code from my version, without button with onload function:

<html>
  <head>
    <title>NoSleep.js - Simple Test Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<script src="NoSleep.min.js"></script>
<script>
      function myFunction() {
  var noSleep = new NoSleep();
       noSleep.enable(); // keep the screen on!
       document.body.style.backgroundColor = "green";
    }
    </script>
  </head>
  <body onload="myFunction()">
    <h1>NoSleep Test Page</h1>
  </body>
</html>

And this is the code from the original version:

<html>
      <head>
        <title>NoSleep.js - Simple Test Page</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
      </head>
      <body>
        <h1>NoSleep Test Page</h1>
        <script src="NoSleep.min.js"></script>
        <input type="button" id="toggle" value="Wake Lock is disabled" />
        <script>
          var noSleep = new NoSleep();
          var wakeLockEnabled = false;
          var toggleEl = document.querySelector("#toggle");
          toggleEl.addEventListener('click', function() {
            if (!wakeLockEnabled) {
              noSleep.enable(); // keep the screen on!
              wakeLockEnabled = true;
              toggleEl.value = "Wake Lock is enabled";
              document.body.style.backgroundColor = "green";
            } else {
              noSleep.disable(); // let the screen turn off.
              wakeLockEnabled = false;
              toggleEl.value = "Wake Lock is disabled";
              document.body.style.backgroundColor = "";
            }
          }, false);
        </script>
      </body>
    </html>

Any idea?
Thank you!

1 Like

Hi @io.nut.ilie

Please donā€™t just mention a bunch of people in the community to get a faster reply.

My quick guess would be that maybe the OS does prevent JavaScript from being run without user interaction (onload) when the battery saving mode is on. Javascripts often consume quite a lot of energy so it would make sense to disable ones that just load in the background when the battery is low :thinking:

Best, Chris

1 Like

Thank you.

Hi, @io.nut.ilie! :wave:

Should we consider your problem as solved?

Thanks a lot!

P.S. Anytime you would like to mention me, please mention @kartik14 instead of @kartik (@kartik is discontinued account, so I might not get any message.)

Thank you @kartik14 for your replay!
I understand what may be the cause but this is not the solution.
I need to have in a way the trigger it with a Thunkable button, that will generate more actions, beside the enabling of the NoSleep.
:pray:

1 Like

Hey, does it make any difference if you have the html file loaded from online or native? How about if you have the webviewer call the file/address in the code upon screen loading?

Thank you @hhuman.
I am not sure how to implement it native and for the moment I just abandoned it the project.
Anyway, the idea of keeping alive the screen it is essential for many types of apps.

Iā€™m sorry that you put the project aside for now. To implement it in the app, I had to add the js script to the header of the html file itself and just uploaded as an asset and set webviewer block to wakelock.html in the code block upon screen loading up.

I combined your auto wake lock function and the original toggle button together in the body of the html file and it locks upon startup for my devices. So in case it doesnā€™t auto lock, the button is right there for the user to enable themself. The only thing is that for some devices, it doesnā€™t disable when they click disableā€¦ not a big problem.

So thank you for sharing your work above that my app is now improved.

*This is all for android that I am talking about btw. Not sure about iOS.

really wish there was a way for this i have a podcast app and have to have the player load externally But i had another streaming radio app which played in the background but dont seem to have that option here on thunkable

Hey Thunkers,

I found 2 threads on talking about keep the screen active while the app is open. As mentioned in those threads, the screen times out according to the phones setting. Which is usually 30 second, I like other thunks would like my screen to remain on longer then the 30 seconds while the user is using the app. I read the setting in the phone cannot be changes with thunkable x. I tried to run a timer and change the textā€¦ My phone still went black in 30 seconds. Then I saw some threads about ā€œKeep the screen active by looping webview with a video assetā€¦ā€ Iā€™m not exactly sure if someone can explain or help me do this, because it seems likes its the solution to my problemā€¦ Unless anyone has any other thoughts.

Thanks,
Rob