That leaves you with two options:
https://ullisroboterseite.de/android-AI2-KeepAwake-en.html
that might work.
That might just be an issue of how you coded your app. You did not share your Blocks so one can only guess why the app 'restarts' ... what does that mean?