Here are two ways to keep the device from sleeping. These are not running in the background but force the device to not sleep, to stay awake. Either method allows you to use your device (awkwardly) as a 'long' timer. That capability ability comes with a cost .. the device needs to be plugged in probably.
Here is how you might code a Stay Awake block routine using a Notifier
or you could use Taifun’s Tools Extension: App Inventor Extensions: Tools | Pura Vida Apps
Using either an extension or a block routine drains your device battery rapidly . These work around methods are not running the app in the Background, they force the app
screen to stay open .
The real solution is to create your timing app with the professional Android Studio, B4A or Delphi Community Edition or a similar compiler that can create a Service app (an app that can run continuously in the background). App Inventor 2 cannot do this.
Another way is to link your app to a Timing App (like Tasker: there are possibly others, maybe free) and use the Timing App to induce the alarm. Wake-up the app to alarm - #4 by Taifun
Regards,
Steve
