Why does magic text fg_app_name SOMETIMES show as Macrodroid?

AMG47

New member
The large picture is I have a macro which mutes sound and I thought I'd add a display to help me learn the names of the apps running when I trigger it.

My question is why it sometimes displays an app name like Youtube then the floating text quickly changes to Macrodroid but SOMETIMES it ONLY shows Macrodroid and not the name of the app that was running.

When I start YT fresh, it usually does the first thing but rerunning the macro after that just displays Macrodroid.

What I WANT is for it always to show me the app name of the foreground app running when the macro was triggered.
iMarkup_20231002_102039.jpg
 

Endercraft

Moderator (& bug finder :D)
This is because MacroDroid sometimes creates overlays, and it's detected by itself. For some reason it doesn't switch back however this behaviour should change to really only show the foreground app.
 

sampleuserhere

Active member
It seems that the event callback result used by MD doesn't represent the actual foreground app.
Take a look the first page of the thread.

 

AMG47

New member
uuhhhhh so in other words, it doesn't always work as hoped or as expected. I see. Thanks. Good to know.
Is this a bug waiting to be fixed? Is there any known workaround aside from perhaps only triggering for a list of apps then using the "which trigger activated me" type of logic?
 

MacroDroidDev

Administrator
Staff member
There are some known issues with foreground app detection, which seems to have got worse in recent times (I guess due to changes in Android). It is definitely well on my radar to try and find solutions to this but it's not neccesarily an easy fix as I rely on what the system tells me is the foreground app package and it seems it's not always correct.
 

sampleuserhere

Active member
uuhhhhh so in other words, it doesn't always work as hoped or as expected. I see. Thanks. Good to know.
Is this a bug waiting to be fixed? Is there any known workaround aside from perhaps only triggering for a list of apps then using the "which trigger activated me" type of logic?

Use plugin like TouchTask with its Read Screen action. The entry "app names" returns a JSON array of visible windows and their respective window type is returned by "window types".

Those app name(s) with "application" as the window type is the one you're looking for.
 

MacroDroidDev

Administrator
Staff member
@sampleuserhere Thanks for the steer.

I think I've got a big improvement based on this where it will read the active windows and cherry pick the one classed as an application (from this I can then find the app package name) and only report updates based on that. After a small amount of testing it appears to work great, but I need to do much more testing of other scenarios.

This will go into the V5.38 release as v.5.37 is on the brink of release and adding new features and anything that might be risky is not possible.
 

sampleuserhere

Active member
@sampleuserhere Thanks for the steer.

I think I've got a big improvement based on this where it will read the active windows and cherry pick the one classed as an application (from this I can then find the app package name) and only report updates based on that. After a small amount of testing it appears to work great, but I need to do much more testing of other scenarios.

This will go into the V5.38 release as v.5.37 is on the brink of release and adding new features and anything that might be risky is not possible.

Great news!

The other scenario I could think of is when there are multiple application window types. Usually it happens when there is an app in PIP mode or the screen is split.
 
Top