As we know, after a certain time the Android device goes inactive. And if the device is sleeping, for example a countdown ends without alarm ...
There is no perfect solution with App Inventor to refrain the device from sleeping, because all solutions will drain the battery of your device!
Please use these workarounds wisely!
There are the following possibilities:
Include a videoplayer component width x height = 1x1, the videoplayer component must be visible on the screen. Upload a small dummy video. Start the video. In the video completed event start it again (or under some condition desired). By playing the video the application is running without sleep. It fades out the screen, then black, but the application still is running.
This does not work for all components, but it works fine with the Player component.
Thank you freesfx.co.uk for the car alarm sound.
You might be interested in the simplified countdown example for App Inventor 2 provided by richard.
These are the blocks used for the "wake lock"
Further blocks used
Tested successfully on Nexus 5 running Android 5.1.
Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!
or donate some mBTC to Address:
Thank you! Taifun
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.