what i want is simple:
As soon as I drive, I automatically launch speedtrapp alert (which will be found in the background), Android auto and then I can manually launch Google Maps for example.
The problem is that as soon as I restart after a stop like at a red light, Speedtrap alert then android auto are restarted. which is not really ideal when driving but especially since Google Maps already launched is then found in the background. Really not the ideal. We totally agree ?
My goal is then to only launch all actions if speedtral alert and / or android auto are not already started. One launch of these applications and only when I start my travel. And not after every stop. Imagine the thing if I get stuck in traffic and get stopped every 100m!
And there the problem is that I cannot detect the fact that these applications are already launched. The loop "if the application is not started then I start the application" does not work. Why ? An idea ?
I don't know the root of your issue. Speedtrap? Does it have any relation with MD macro itself? What are you dealing with MD. I had never seen your macro and it is very hard to understand just reading your comment. New apps and new situations are raising up in every posts.
Anyway, even if you have no idea to stop the alerts of Speedtrap and it should be foreground every 100 meters, don't worry, MD can help you. MD have a ability to detect your activity with motion sensor as a trigger. If detect as still and fire the trigger, you can check the foreground app in a if statement in your macro actions.
if foreground app is not Google Maps, simply launch it wherever it is, foreground or background. It should be back again.
If detecting your activity is not good enough, you can use interval trigger as well. Set the trigger working every 1 minute or something and execute Google Maps as a backup action.
These two triggers make it keep on being foreground automatically.
If I were you, looking for Speedtrap alternative and I couldn't find good one unfortunately, simply would give up and stop using such a annoying app though.