global variable

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

global variable

Post by Rafi4 » 01 Dec 2018 04:06

hi Martin and all
give me one example about global variable trigger.
thanks from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: global variable

Post by digitalstone » 01 Dec 2018 13:38

Not much to explain really.
You type the glovar inside the trigger, and then when the value of that glovar changes, the flow will be triggered.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Helios
Posts: 17
Joined: 22 Oct 2018 09:41

Re: global variable

Post by Helios » 05 Dec 2018 10:53

Maybe it is notable that changing a List or Map by, for example, adding or altering elements, does not trigger the flow.
It is only triggered if a new value is assigned to that global variable.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: global variable

Post by digitalstone » 05 Dec 2018 19:09

That is correct.
Variables that contain multiple values within such as lists and maps are not usable in this trigger.
The reason is (AFAIK) that Martin has no control over how many variables the user puts inside that map/list.
In which case Automagic could overload the user's phone with, let's say, 100 instances running on a single flow every second... that would be a problem.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: global variable

Post by Desmanto » 09 Dec 2018 17:51

If you want to use map or list as the glovar trigger, you have to change the whole map/list at once. You can't add just add/remove one element and hope it will be triggered. If map/list is still needed, you have to use another temporary glovar to identify the change. So you global_database as the map/list, which you can add/remove the element. After add/remove, change other global_temporary_status to something else, and use this as the trigger. At the script, later you can access the element from the global_database.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply