Question about "MacroDroid initialized" trigger

chaoscreater

Active member
Hi,

How does MacroDroid get initialized? If I go into MacroDroid and turn on/off the button on the top right, I would expect MacroDroid to re-initialize itself, but that's not the case. It seems that it only gets initialized when you force close the app and launch it again, or when you restart your phone.

At the moment, I have some macros that use "MacroDroid initialized" as a trigger and they'll update a bunch of variables. However, it seems it only gets initialized when I either force close the app and relaunch it (which isn't ideal, because it'll lose all the permissions that I've configured, such as Draw over app, Accessibility permissions, etc), or that if I restart the phone, it obviously initializes MacroDroid when it auto-launches on startup. Both of these methods are tedious and annoying though, so I was wondering if there's a simple on/off switch to re-initialize MacroDroid?
 

Jacob L

Moderator (Lawsonator)
Macro enabled trigger. It's new so make sure MacroDroid is updated first. You can long click any trigger, action or constraint to see what it does or press the ? at the top next to the search
 

chaoscreater

Active member
I'm aware of the '?' symbol, but it doesn't tell me much in this case. My MacroDroid is always up to date as well.

I'm also aware that it's a macro enabled trigger. However, my understanding is that this trigger only activates when MacroDroid itself is initialized and I'm not sure how this initialization takes place. If you force close MacroDroid and launch it again, this "initializes" MacroDroid. However, if you disable MacroDroid (via the top right toggle button in the home screen) and then enable it again, it does not initialize MacroDroid. Like, it's not very consistent how this initialization takes place.
 

Qarboz

Well-known member
As I understand, MacroDroid initialized happens when MD has been launched, has finished loading and is running. Disabling and re-enabling it does not change the loading and running status. If you want to update variables on demand, I think you should add a "MacroDroid Button" (or other) trigger to macros where you need to update variables. Or create a new macro, activated with a button trigger (or other), where you update the variables; this you can do if the variables to be updated are all global and if their value does not depend on the macros where they are used
 

MacroDroidDev

Administrator
Staff member
The enabled trigger will only run once when the app process is created. It was added as an alternative to the device boot trigger as on some devices it takes a long time for device boot to fire and the initialised trigger may fire much sooner.

I'm surprised to learn that you are losing all your permission when you force close the app. What device is this happening on?
 

Jacob L

Moderator (Lawsonator)
I'm surprised to learn that you are losing all your permission when you force close the app. What device is this happening on?
This does also happen on my devices. If you set MD as device assistant and device administrator, it prevents the OS from killing it
 

chaoscreater

Active member
This happens to all my devices (mostly Xiaomi phones on stock rooted ROM, but also on custom ROMs too. They all run Android 11).

MD is already set as device assistant but not device administrator. I might give that a try. It's not really a big deal since I don't ever force close the app. And it retains all the permissions after I restart my phone, so it is just a bit weird that force closing it somehow breaks the permissions.
 
Top