Trigger: application minimized, application closed, application disabled.

Symbian

New member
Dear developer! I make a huge request. Please add a trigger, when the application is closed (swiped) by the user from the list of open applications. After all, when an application is minimized, closed and disabled are three different things. The "Applications Launched/Closed" category has a "Closed" trigger, although in fact, it can just be minimized and the trigger will work. This is very inconvenient.
 

Pseudocyclic

Well-known member
I believe the problem with this is that Android doesn't broadcast the information that the MacroDroid trigger you are requesting would need to receive in order for it to work.
 

Symbian

New member

@Pseudocyclic

Well, I'll think about it, thank you. Tell me please, do you know any way to set the "Application is closed" trigger so that it's not triggered when the application is minimized, but when it's closed?
 

Symbian

New member

@Pseudocyclic

@MacroDroidDev


Thank you very much for answering me, now I will know it. I don't know a lot of things, like what happens with the application at code level and because of that I can ask silly questions, I apologize in advance for that, I'm trying to learn more and more.
Can we say that when the application is closed and when it is open but not in the foreground are the same state from a code perspective? That is, on Android 8+, in both cases the app does not show any activity?

Is it possible to add a "App not running" trigger ? This trigger would work if the app is not presenting any activity and, theoretically, this could be used instead of closing the app. That is, this trigger would constantly check if the application is running in the foreground and in the background, and if the application is not running in both cases, the trigger would work.
 

Dm114

Well-known member

@Pseudocyclic

Well, I'll think about it, thank you. Tell me please, do you know any way to set the "Application is closed" trigger so that it's not triggered when the application is minimized, but when it's closed?
To summarize I would say that an app is considered to be closed when it is not in foreground anymore (either really closed, or in background)
 

Symbian

New member
To summarize I would say that an app is considered to be closed when it is not in foreground anymore (either really closed, or in background)
You're right. But now I'm trying to figure out what happens to the application at the code level when it is closed and when it is minimized (open, but not in the foreground)
 

Pseudocyclic

Well-known member
You're right. But now I'm trying to figure out what happens to the application at the code level when it is closed and when it is minimized (open, but not in the foreground)
What happens is Android handles this, not MacroDroid. And Android doesn't make the information you want available to other apps.

Apps cannot support things that Android does not support. Sometimes there is a workaround but in this case, like many others, there is not.

To pursue this further, try asking on an Android forum, not an app forum.
 

dsnz

Well-known member
@Symbian
a possibility would be to check with the logcat trigger for a last message from the app you are interested (last message before app stops running, sounds strange but is often possible thought it's very app specific)
also there may be Android message when the app is finally killed for example a WIN DEATH message - which I do see on my Android - though you must experiment with Logcat Reader app to find the exact messages for your Android version and you must know the real name of the app eg. something like com.company.app
 

Symbian

New member
Hi

@Pseudocyclic

@dsnz

@MacroDroidDev

, and everyone else.
I finally managed to create a macro that enables the VPN(you can choose any other action) when you open the app, and disables the VPN exactly when you close the app from the list of running apps.

I used "Logcat Message" in the Device Events category as a trigger for full closure the app, in the "Component" field I entered: UsageStatsService, and in the "Enter text to match" field I entered: Unexpected activity event reported! (com.appname.android.
This trigger worked correctly only with this message from the logs, you may have another, try it.
Galaxy S20 phone, Android 12

I'll post the template on the site a little later
 
Top