Force app to stay active
Go to Settings -&gt; Apps &amp; notification and list all applications.
Select your Application, expand the menu &quot;Advanced&quot; and choose &quot;Battery&quot;:

check that your App does not have any restriction and can use battery in background


Go to &quot;Battery optimization&quot; and list &quot;All apps&quot;. Find your application, click on it and choose &quot;Don't optimize&quot;.