Skip to first unread message

David Moreno

unread,
Jan 13, 2015, 3:41:11 AM1/13/15
to mitappinv...@googlegroups.com
Hi there!
Is it possible to keep the screen on while the app is running?
Thanks!
David

Ghica

unread,
Jan 13, 2015, 8:07:23 AM1/13/15
to mitappinv...@googlegroups.com
Yes, 
There is a trick I read somewhere, but I cannot find a reference to it anymore.
You add a notifier and a clock, not used for other purposes in your app. Set the clock to a rather long interval, 10 seconds or so. Maybe even a minute would work fine, depending on the setting of your phone.
Make the background color of the notifier transparent.
When the clock.timer fires, display a warning that is an empty string. In this way you will not see it, because of the transparent background.
It keeps your phone awake for as long as you want and as long as your battery stays alive (which may be considerably shorter).
Cheers, Ghica.

Taifun

unread,
Jan 13, 2015, 9:10:10 AM1/13/15
to
you can't keep the screen on
Edit: not correct, see test project below

the trick Ghica is referring to, is to keep the app running, but this does not work reliably
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Ghica

unread,
Jan 13, 2015, 9:22:20 AM1/13/15
to mitappinv...@googlegroups.com
As far as my experience goes, it does keep the screen on too.
Cheers, Ghica.

SteveJG

unread,
Jan 13, 2015, 9:45:36 AM1/13/15
to
My experience also indicates using a Notifier and a Clock keeps the screen on  (other than a battery drain issue)...what might be anissue are the device's Settings allowing the app to go to sleep or not go to sleep.  What they are set to might not allow this on some devices or versions of Android.   I suspect some Android OS activities might interfere with this technique but so far, in my app no issues.    Your recommendation Ghica appears as good as any and possibly better than using a video file in a loop to make AI2 stay 'alive' at the expense of other issues.  ....and is A SOLUTION until AI2 can work in the background .

Taifun

unread,
Jan 13, 2015, 4:08:28 PM1/13/15
to mitappinv...@googlegroups.com
great, it really works too keep the screen on (at least on Nexus 5 running Android 5.0.1)... 
thank you Ghica!
see test project attached... 
after 20 minutes without touching the device the screen still was on...



Taifun
screenOn.aia

Ghica

unread,
Jan 13, 2015, 4:20:50 PM1/13/15
to mitappinv...@googlegroups.com
Taifun,
Thank you! After seeing your links, following these must have been how I found the trick.
Cheers, Ghica.

David Moreno

unread,
Jan 15, 2015, 10:16:44 AM1/15/15
to mitappinv...@googlegroups.com
Thanks for your amazing help! :)
David.
Reply all
Reply to author
Forward
0 new messages