0

I think this would be useful if you're entering data into a form, but you don't want to accidentally press "submit" when there's no Internet, causing you to have to re-enter everything.

Also, it would be nice for macros. Say you have a macro doing something on an app that requires Internet. When the Internet fails, the macro goes haywire by clicking on random stuff it's not supposed to click. It would be best to lock the screen in that case.

I have Android 4.4.2. I do not have cellular data on this phone.

6
  • 1
    Tasker / MacroDroid should be able to do this.
    – Firelord
    Jun 22, 2019 at 19:51
  • 1
    Define wifi cut off. Wifi enabled but not connected or Wifi disabled? Jun 22, 2019 at 20:05
  • 1
    I assume you really meant "checking if the device is connected to the internet" since there's also a possibility to use mobile data when the WiFi fails, or the device is still connected to the WiFi but not connected to the internet.
    – Andrew T.
    Jun 22, 2019 at 20:11
  • @ReddyLutonadio Yes I mean when Internet cuts off in general, but the phone has no data, so just Wi-Fi disconnected Jun 22, 2019 at 20:57
  • 1
    Just out of curiosity, does anyone know if there's any comparable method similar to this but for Android (i.e., examining browser header/POST data)? It would also resolve the OP's problem, while also circumventing potentially annoying scenarios, e.g., experiencing intermittent connection loss while trying to use their phone.
    – Arctiic
    Jun 23, 2019 at 11:37

1 Answer 1

1

Using Macrodroid:

  1. From the drawer, select variable and create a global variable of type boolean. Set it to false and save.
  2. Create a macro. On the Triggers tab, on the Connectivity section, select Wifi Enable.
  3. On the Actions tab, on the Conditions/Loops section, select Repeat actions, then "While condition repeat". On the Condition, go to the Connectivity section, select Wifi State, then Wifi is connected to, finally select Any network.
  4. On the Actions tab, on the Macrodroid specific section, select "Wait Before Next Action", set a time (I set it at 1mn).
  5. On the Actions tab, on the Connectivity section, select Connectivity check. Enter a website that the macro will keep checking if there is an internet connection to it or not. Set the timeout. Click the + and add a variable.
  6. On the Actions tab, on the Conditions/Loops section, select "If clause", under Macrodroid specific, select Macrodroid variable and choose the variable created on the previous section. Set its value to False.
  7. On the Actions tab, on the Screen section, select "Screen On/Off", choose Screen Off.
  8. On the Constraints tab, under the Screen and Speaker section, select "Screen On/Off", choose Screen On.
  9. Give the macro a name and save it.

The macro will look like the image below. Click the up and down arrows on the Actions section, to be able to move the actions up or down. Click the 3-dot on the top right and select Test Macro.

Lock screen if no internet macro

Explanation: When the macro starts, it checks if Wifi enabled and the device is connected to any network. It waits for a certain time before checking if there is a connection to the website enter in step 5. If after the set timeout in step 5 there is no connection, the screen will be switched off.

The delay in step 4 also serves as a fail-safe mechanism when you switch the screen on again to allow for example to disable the macro.

Note: To see the Conditions/Loops section under the Actions tab, the macro must be saved. Then when opened for an edit, the section will be visible.

5
  • This is awesome! I haven't gotten it to run yet because I can't find the "conditions/loops" section. There doesn't seem to be one. I tried looking for similar words but no luck. Trying to find it. Is it on the full version only maybe? Jun 23, 2019 at 1:16
  • 1
    @CreativiTimothy Save the macro, then edit it. The Conditions/Loops section will appear under the Actions tab Jun 23, 2019 at 1:38
  • Nevermind, I found it. You have to save the macro first, and then you can add conditionals to it, or maybe I just suck at using the interface. Testing now and got it worked. You're a life savior! Jun 23, 2019 at 1:38
  • I was thinking of a suggestion. If we add the 1 min delay outside of the while/do loop, would it be better since it will be checking WiFi connected as fast as possible? I think the 1 min delay would act as a fail-safe mechanism when your Internet turns back on and off super fast. Jun 24, 2019 at 1:06
  • 1
    I have not tested it with the delay outside the loop. But I did without the delay and it was too fast for my liking that is why I introduced a delay. Test your suggestion about the delay outside the loop. Also try increasing/decreasing the timeout of the website. Jun 24, 2019 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .