Search code examples
androidbackgroundmonitoringtasker

Creating a background monitoring app using Tasker


I have a working project in Tasker, the famous Android automation app. Its main profiles monitor the system logs (via the logcat trigger) for an event, and run tasks that optionally display a pop-up and enable Do Not Disturb.

Everything works as expected in Tasker, but when I export the project as a standalone app, these profiles fail to trigger.

I suspect I'm missing something about how exported apps work in the background. The overall outline is that I would like to create an app that waits in the background until an event occurs, then execute a task - just like Tasker itself.

A TaskerNet link to my project is attached below. It is designed to trigger when certain Moto Mods are connected, so unless you have a Moto Z series phone, you'll need to change the triggers to test it.

https://taskernet.com/shares/?user=AS35m8k80GaDd5dXaSh1zON%2FjeGpbCvKMUpxEUgWrnJlmyY98C1z2BEwlM1TmxR2BoGhlXGYlNWh&id=Project%3AMoto+Mod+Mute

Edit: Adding the "Ask Permissions" command for reading system logs and managing Do Not Disturb seems to have helped. I have yet to test the logs portion, but am getting the proper prompts from the exported app now.


Solution

  • As I noted in my edit to the question, I later added an "Ask Permissions" command to my app's launch task. This caused it to prompt for the required permissions, which partially worked, guiding the user to the Do Not Disturb access page to grant that permission. The other required step, in my case, was to use ADB to grant my app android.permissions.READ_LOGS. This allowed it to, well, read the system logs, in order to check for Moto Mod attachment events.

    To summarize, if your app isn't responding, check its permissions!