Run macro before all other macros at startup

J70P

New member
Why do you think this is necessary? I'm sure you have a good reason. I'm not aware of any triggers due to Macrodroid restarting, at least I do not see any when I toggle the enable/disable switch.

The only thing I know how to do is detect device start, as previously described. I don't see a way to detect app crash and restart. Can you describe why you need to do your special actions on app restart?

I think it's common practice in software development or software in general to set default values for variables at startup, read configuration files, or check prerequisites in general. In software development, every object has a constructor for that purpose. No matter whether the program is started by a system restart or by Android. The stopwatches example of Abalsam is an example of why you should do it.
 
I think we're talking about two different problems.

How to handle restart and how to handle abnormal end. Abend, we called it...

Restart is easy. We've discussed it here with trapping shutdown and initialize triggers. Multiple ways of doing that. All good

Abnormal end, harder. The app may know the end was abnormal, I don't know. I know that my testing show that macrodroid is all screwed up when I force stop it, but I don't see any trappable triggers when I start it after force stop.

My experience is that an ungraceful app termination yields an ungraceful restart. Sometimes really ugly, like the loss of the next business day while databases are restored

I'm watching this thread for answers.
 

Dm114

Well-known member
I want a macro to be executed before all others when MacroDroid starts, for example to set initial values for variables. There is "Device Boot" and "MacroDroid Initialised". But both don't seem to run before any other macros. Tasker has the "Monitor Start" trigger for this purpose. Is there something similar in MacroDroid?
You could use the macro below to initiate a boolean variable at shutdown/reboot time. Don't add any other actions because MD won't have time to execute them before effective shutdown.

Then change its value to True at the end of your boot time macro (don't forget to tick Wait untill complete.. boxes whenever needed in the appropriate actions).

At last, add a simple global Constraint to every macro that needs to wait for boot completion (Constraint → global variable BootComplete=True)

Anyway, I'm wondering how/when your other macros fire? Don't forget that if you prevent them from firing at the time the triggering events occur, they won't fire again untill other similar events occur.

N B.: I used a local boolean variable in the example below to show its value but you must use a global one instead for every macro that needs it can acces it.
 

Attachments

  • 20220419_101306.jpg
    20220419_101306.jpg
    268.4 KB · Views: 10

Qarboz

Well-known member
Anyway, I'm wondering how/when your other macros fire? Don't forget that if you prevent them from firing at the time the triggering events occur, they won't fire again untill other similar events occur.


That's what I attempted to explain in #14
I think that in the various macros that have to wait for the execution of the "master" macro as the first action there should be a while/do with the condition of the Macrodroid mode (or the boolean variable = true)

But of course my English is bad...
 

Dm114

Well-known member
That's what I attempted to explain in #14


But of course my English is bad...
No, your English is not bad (it's not my native language either) but I didn't have all the answers in memory as this thread has many posts (and not all of them are suitable to solve the guy's problem)... 😉
 
Top