Note: with the extension feature, this workaround is now obsolete. Thank you MIT!
Now you can use my Tools Extension and its KeepScreenOn method instead.
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:
Description:
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.
Note:
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:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Thank you! Taifun
Download aia file for App Inventor
Back to top of page ...
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.