Is a program running?

57 views
Skip to first unread message

Bill DeWitt

unread,
Jul 9, 2021, 11:21:10 AMJul 9
to Tasker
Can I find, in a Task, if a certain program is running on my phone?

jmjc...@gmail.com

unread,
Jul 10, 2021, 4:59:40 AM (13 days ago) Jul 10
to Tasker
if you mean the current app in the foreground, yes. You can use the Application context.

Bill DeWitt

unread,
Jul 10, 2021, 6:15:14 PM (13 days ago) Jul 10
to Tasker
Thanks for the reply, but no, I need it for a background program and I need it in a task, not a profile. I want to toggle it based on a location profile. 
Maybe there's another way to do what I want.
Calls to it either turn it on if it's off, or turn it off if it's on. This works most of the time. 
But when it doesn't work right it's off kilter until I manually check up on it. So I want to build in error checking. Don't try to turn it off unless it's actually already on. 
Thanks again. 

jmjc...@gmail.com

unread,
Jul 10, 2021, 9:50:43 PM (13 days ago) Jul 10
to Tasker
I see. What have you tried so far? Mind sharing your task description?

Rich D

unread,
Jul 10, 2021, 10:29:08 PM (13 days ago) Jul 10
to Tasker Google Groups Post
 I need it in a task, not a profile. 

You can get the current app and activity with the Tasker function action.  

Bill DeWitt

unread,
Jul 10, 2021, 10:43:22 PM (13 days ago) Jul 10
to Tasker
So far it's just one line. If I'm away from the house, "Launch App". When I return, "Launch App" again. That toggles it. 
There's nothing I can find that could be used to make it differently. Unfortunately, "Kill App" doesn't work for it.  

The program is BVR (Background Video Recorder) and the profile checks my connection to my wifi. 

Rich D

unread,
Jul 11, 2021, 6:59:20 AM (12 days ago) Jul 11
to Tasker Google Groups Post

So far it's just one line. If I'm away from the house, "Launch App". When I return, "Launch App" again. That toggles it.


It sounds like this app is running a service in the background. If it has a notification in the notify bar you can test for that with auto notification.  Or you should be able to jmjc's first suggestion and make a app context in a new profile with the services option checked. Just link that to a 'dummy' task with a stop action in it. You can then test to see if that profile is active from your other task by using the %PACTIVE variable. 





ktmom

unread,
Jul 11, 2021, 9:44:10 AM (12 days ago) Jul 11
to Tasker
If the device is rooted, you can use a shell command, "pidof", to determine if an app is active, even if it's in the background.  

In this example, the app is Brave (a browser). You need too ensure "Use Root" and "Continue Task After Error" are enabled. The command is "pidof <package name>".

If the app tested is running, it will return a number.  If not running, the Run Shell action will fail and %pidof will not be set.

A1: Run Shell [ 
           Command: pidof com.brave.browser
           Timeout (Seconds): 0 
           Use Root: On 
           Store Output In: %pidof 
           Store Errors In: 
           Store Result In: 
           Continue Task After Error: On 
      ] 
   
      A2: Flash [ 
           Text: %pidof 
           Long:On 
      ] 

Bill DeWitt

unread,
Jul 11, 2021, 12:58:10 PM (12 days ago) Jul 11
to Tasker

" you can test for that with auto notification"

That should work. I haven't used AutoNotification for anything yet, I'll give it a try. Does it have a distinct action for that or will I need to fuss around with it?
Thanks for the reply. 
On Sunday, July 11, 2021 at 6:59:20 AM UTC-4 Rich D wrote:

Bill DeWitt

unread,
Jul 11, 2021, 1:00:31 PM (12 days ago) Jul 11
to Tasker
Unfortunately, not rooted. It's a newer phone and I usually wait for people to make all the rooting mistakes for me first. I should probably do that now though, I'm sure the methods have settled down. 
Thanks for considering this question and replying. 

jmjc...@gmail.com

unread,
Jul 11, 2021, 6:53:32 PM (12 days ago) Jul 11
to Tasker
If you are talking about BVR, then by default, when it is recording, there should be a notification. You can definitely use the AutoNotification Query action to detect that.

Bill DeWitt

unread,
Jul 11, 2021, 11:51:10 PM (12 days ago) Jul 11
to Tasker
Yes, that seems to be working. I have to go back in at some point and do the detail work of distinguishing between notifications I think, but with a quick test I did get a tasker alert when BVR started and stopped.
Unfortunately I had other plans for today and might not get to it until later tomorrow. 
Thanks again to everyone, I appreciate the help. 

Reply all
Reply to author
Forward
0 new messages