I am new to Macrodroid, but an experienced C# programmer (if I may say so
). I don't know how to test an action manually. I use a primitive 'if value is so and so, then play a specific sound'.
My problem: I want to launch a navigation app on my Samsung A23 phone, when i start my car engine which means the power to my phone gets connected. On my desk this is working fine, But in my car the launch sometimes fails, probably because of power interruptions during the start of my engine.
The solution I have in mind: Repeat the launch of the nav app if it is not running in the foreground. A loop seems ideal for this. I did not find a loop action, so I created a 'Launch loop' macro (empty triggers, no constraints) which calls itself upon no success Something like this in pseudo code:
global integer giCounter=0
Macro Run (Launch loop)
Macro Launch loop
Set Variable giCounter: (+1)
if {v=giCounter}>3
Cancel Macro Actions (this macro)
end if
Launch nav app
(Wait a few seconds)
if not foreground: (nav app)
Macro Run (this macro)
end if
As you can see, MD should make a maximum of three attempts, but when I try this, it keeps running for ever. Upon inspection giCounter turns out to remain always 0.
All other macros and actions are working fine in my project and when I try it in my car (except for the multiple launch attempts), all is right. The giCounter variable is not used elsewhere in my code.