App inventor and Task

Services has been abandoned.

What you can do is use a Stay Awake routine.

The best you can do is prevent the screen from closing using a Stay Awake routine .

Either use a Stay Awake block routine using a Notifier

or you use Taifun’s Tools Extension: https://puravidaapps.com/tools.php

Be aware 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.