Constraints

Sobczynd

New member
I have a pixel 7 that always loses signal, so I created a macro to turn airplane mode on and off every 15 minutes refreshing the network. The problem is with the constraints. I don't want this to run when I'm on a call, it's ringing, or using GPS. I've tried using not in call or not ringing or GPS not enabled. I've also tried the opposite to those and the macro still runs and drops the call I'm on.

Help please.
 

Dm114

Well-known member
I have a pixel 7 that always loses signal, so I created a macro to turn airplane mode on and off every 15 minutes refreshing the network. The problem is with the constraints. I don't want this to run when I'm on a call, it's ringing, or using GPS. I've tried using not in call or not ringing or GPS not enabled. I've also tried the opposite to those and the macro still runs and drops the call I'm on.

Help please.
Set the constraints you listed as Global ones (for the whole macro). It must work: I use some of them.
 

Sobczynd

New member
Set the constraints you listed as Global ones (for the whole macro). It must work: I use some of them.
Thank you. How is that done, I don't an option to set globally. Also shoukd they be set to in call or not in call, both seem to drop and active call.
 

Dm114

Well-known member
Thank you. How is that done, I don't an option to set globally. Also shoukd they be set to in call or not in call, both seem to drop and active call.
In the green area called Constraints at the bottom of the macro editor screen
 

Sobczynd

New member
Yes I see that, but I don't see any option for global. Right now I have it set for not in call or not ringing or GPS enabled.
 

Dm114

Well-known member
Thank you. I tried that and the macro doesn't run at all. Apologies, New to this. View attachment 9177
How do you want it to works as you activate and deactivate airplane mode at the same time? 😁

Do you want to activate it OR deactivate it?

Depending on your Android version I'm not sure activating/deactivating Airplane mode is stil allowed... 🤔

Let's ask users who have a more recent Android version, mine is old enough to have no trouble. Which one is yours?
 

Sobczynd

New member
What I want to do is every ten minutes turn on and off airplane mode to refresh the network. I don't want this to happen though if I'm on a call, getting a call, or using GPS. I tested this with using or and not and and the macro works, however it will drop a call when I'm talking and it runs. So basically I just need to figure out how to not have the macro run when any of those three things occur.
 

Dm114

Well-known member
If you want to activate/deactivate to force system to reset connexions, you must add a long enough delay to allow system to update its configuration. Let's say 5 to 10 seconds at least between 2 Airplane actions.
 

Dm114

Well-known member
Instead of adding a delay you could test Airplane mode state, i.e. set it On when it is (really) Off. To do that I would make this:

A: Airplane On
A: While Airplane Off
A: Wait 2 seconds
A: Loop
A: Airplane Off
 

Sobczynd

New member
Instead of adding a delay you could test Airplane mode state, i.e. set it On when it is (really) Off. To do that I would make this:

A: Airplane On
A: While Airplane Off
A: Wait 2 seconds
A: Loop
A: Airplane Off
Are you able to show what that would look like? I'm not seeing all these options. Screen shot like before?
 

RSF

Well-known member
Re: constraints, and the macro no longer running at all when switching to "AND" to connect constraints...
A possible problem is that GPS Mode is permanently on or off, depending on your location settings. It doesn't go on and off during the day depending on whether one or more apps is actively using the location service. Therefore, unless you manually turn off the Location Service in Android, "GPS Disabled" is always going to be False, and therefore the macro will never run.

If you want to prevent the macro from turning on Airplane mode while you're using an app that requires location, e.g. Maps or Waze, you could try a constraint detecting when those app(s) are in the foreground with the "Not Foreground" constraint vs. the GPS Enabled constraint you had:
1711557452585.png
 

dhj49er

Well-known member
In your macro you either need to put a wait action of at least 2 seconds between the airplane on/off actions.

An alternative to a wait is to use system setting change - see the attached screenshots.

The last wait until trigger is not essential for your macro.
 

Attachments

  • Screenshot_20240327-163447~2.png
    Screenshot_20240327-163447~2.png
    75.3 KB · Views: 7
  • Screenshot_20240327-163346.png
    Screenshot_20240327-163346.png
    117 KB · Views: 7

Dm114

Well-known member
In your macro you either need to put a wait action of at least 2 seconds between the airplane on/off actions.

An alternative to a wait is to use system setting change - see the attached screenshots.

The last wait until trigger is not essential for your macro.
I'm not sure System settings change is 100% reliable (unless you tried it). It's the reason why I looped on Airplane state instead...
 

Sobczynd

New member
Re: constraints, and the macro no longer running at all when switching to "AND" to connect constraints...
A possible problem is that GPS Mode is permanently on or off, depending on your location settings. It doesn't go on and off during the day depending on whether one or more apps is actively using the location service. Therefore, unless you manually turn off the Location Service in Android, "GPS Disabled" is always going to be False, and therefore the macro will never run.

If you want to prevent the macro from turning on Airplane mode while you're using an app that requires location, e.g. Maps or Waze, you could try a constraint detecting when those app(s) are in the foreground with the "Not Foreground" constraint vs. the GPS Enabled constraint you had:
View attachment 9191
OK almost there. Whwre is the not foreground located under constraints I'm not seeing it. Also, how do I set the 2 second delay between turning on airplane mode and then turning it off?
 

RSF

Well-known member
Whwre is the not foreground located under constraints
Device State / Application Running / Not in foreground

Note that MacroDroid has a handy "Search" function in constraints (and triggers and actions); tap the magnifying glass at the top right of the screen, and type in a few letters (like "app") to see the matching constraints/triggers/actions.
 

RSF

Well-known member
how do I set the 2 second delay between turning on airplane mode and then turning it off?
Couple options...

a) 2 second delay
That "Wait" action is in Macros / Wait before next action. The loop scheme suggested by @Dm114 would look like so:
1711560543164.png

b) "Wait until" airplane mode is on
A variant of that would be to use the "Wait Until" action, similar to @dhj49er 's suggestion, but using a different wait trigger (Airplane Mode Enabled, vs. Setting Changed) since @Dm114 mentioned the system-setting version might not be 100% reliable:
1711560699390.png
 

dhj49er

Well-known member
I'm not sure System settings change is 100% reliable (unless you tried it). It's the reason why I looped on Airplane state instead...
Yes I use it & found it to be reliable.

In any case the continue after the 3 sec timeout would probably mask any unreliability of the setting trigger.

In my experience the phone typically requires a minimum of 2 seconds to change airplane mode state.
 
Top