App Inventor and Scripting Layer for Android (SL4A)


How to refrain your device from sleeping

Please find the new "App Inventor only" workaround here.

As we know, after a certain time the Android device goes inactive. There's currently no direct solution with App Inventor to refrain the device from sleeping, see also this thread and comment 82 in issue 32. And if the device is sleeping, the countdown ends without alarm ...

To avoid this problem, I now set up a countdown timer example together with Scipting Layer for Android (SL4A). From App Inventor, a SL4A script will be called using an activity starter to acquire a partial wake lock and after the countdown finished, another SL4A script will be called to release the wake lock again. The parameters to call SL4A from App Inventor can be found here.

Thank you freesfx.co.uk for the car alarm sound.

There is also this thread which might be interesting for you: How to keep an app running even though the screen times out & locks, which uses Tasker as workaround.

Known issues:
To exit the app with the back button or home button will not release the wake lock. Therefore only exit the app using the Exit button!

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Screenshots


Preparation

App Inventor blocks


Download


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!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download zip file for App Inventor
Back to top of page ...

Creative Commons License
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.


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact