Page 1 of 1

Is there a way to know if an app is active ?

Posted: Sun Apr 28, 2019 3:49 pm
by brunoisa10
In order to restart if stopped by Android

It's for Music widget, when music app is stopped by Android I have to restart it for the controles to be working fine

Unrooted

Re: Is there a way to know if an app is active ?

Posted: Mon Apr 29, 2019 9:18 am
by Pierrot
It should be partly possible by looking at the list of processes. However i'm not sure in what way it would help in solving the issue.

Re: Is there a way to know if an app is active ?

Posted: Mon Apr 29, 2019 10:21 am
by brunoisa10
if the music app is not in the process list I'll be able to restart the app (from a script or from tasker)

Is it possible to build process list in a script ?
I've seen some example but not in javascript (copied on a script and not working but I assume it must be not the same syntax)

Re: Is there a way to know if an app is active ?

Posted: Mon Apr 29, 2019 10:50 am
by Pierrot
There may be some ready to use APIs although this is discouraged by the system goals (I haven't check this for a while), and ultimately it is always possible to list the content of the /proc directory where all processes have a folder which name is their pid.

Any chance to solve the root issue? Restarting the app based on process check seems convoluted and might be fragile :-(

Re: Is there a way to know if an app is active ?

Posted: Mon Apr 29, 2019 1:39 pm
by brunoisa10
I've tried to root but after saying OK, it wasn't.
I can survive : I've set a start of my music app when On screen , with Tasker