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

This is the place to ask "How do I ...?"
Post Reply
brunoisa10
Posts: 88
Joined: Sun Jan 27, 2019 7:31 pm
Location: Westende Belgium

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

Post by brunoisa10 » Sun Apr 28, 2019 3:49 pm

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
Bruno 8-)

User avatar
Pierrot
Site Admin
Posts: 171
Joined: Wed Jan 23, 2019 12:18 pm
Location: French Alps

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

Post by Pierrot » Mon Apr 29, 2019 9:18 am

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.

brunoisa10
Posts: 88
Joined: Sun Jan 27, 2019 7:31 pm
Location: Westende Belgium

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

Post by brunoisa10 » Mon Apr 29, 2019 10:21 am

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)
Bruno 8-)

User avatar
Pierrot
Site Admin
Posts: 171
Joined: Wed Jan 23, 2019 12:18 pm
Location: French Alps

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

Post by Pierrot » Mon Apr 29, 2019 10:50 am

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 :-(

brunoisa10
Posts: 88
Joined: Sun Jan 27, 2019 7:31 pm
Location: Westende Belgium

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

Post by brunoisa10 » Mon Apr 29, 2019 1:39 pm

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
Bruno 8-)

Post Reply