Macrodroid has three powerful conditional statements
WHILE / DO
, which you tried is not suitable. It doesn't work with OR
( background or foreground ) . That leaves us with
IF <conditions> ELSE
which is also not appropriate . Reason you have 4 states , app in Foreground, Not in foreground , Alive in background , Not running - if you choose one state with IF
, ELSE
would cover all 3 remaining states and that's not what you want
That leaves us with two IF
loops , each having the corresponding WHILE
loop nested. Two WHILE
loops in similar fashion may work but I didn't try ( stuck me just now )
Macro would look like this ( didn't add in linked answer so as to keep it simple and I had the macro ready ). Trigger and constraints would remain same. Only actions shown
You may need a second macro ( for user convenience, and to ensure that macro is not active in other two states) to disable this macro. It would have empty trigger and single action of Macro Stop → Lossless Music 2. Go to the widgets section of your launcher , drag and drop Macrodroid widget to your home screen and assign it to the macro just created with empty trigger.
If Google Play Music is inactive as an example , but you are listening to music on another player, you certainly wouldn't want that player to be locked down. Or let's say you like listening to Heavy Metal on Play music with volume at 75% , you wouldn't want the same volume to persist. As additional precaution
I tested this for the other answer , so you are good to go with this
Happy automation with Macrodroid :)