Mobile data enable issue

chaoscreater

Active member
I have an action that turns on mobile data without using root:

[Global] mobile_data0 = 1

When I run that, I can see the mobile data icon toggles on. If I go into Android settings, I can see my mobile data is enabled there as well. However, if I load a page in my browser, it doesn't work. I have to refresh the page a few times for it to finally start loading.

Initially, I thought maybe I just need to wait a few seconds. However, it turns out this is not the case. I have to actually refresh the page in my browser for it to recognize that mobile data is enabled.

I've tried using a Connectivity Check and HTTP GET (without browser) to make them fetch some traffic/data. However, they don't work.

I don't know why Android thinks mobile data is not enabled, even though it is. Is there a way to make this work automatically without user intervention?

I've also tried using "use helper app" setting and it doesn't make a difference.
 

chaoscreater

Active member
I did some more troubleshooting and what I found is this:

When using mobile_data0 = 1, you have to set a wait time of 15 seconds before Android OS will know that mobile data turned on.

Once mobile data is enabled, it will show as enabled in the Android settings and in the notification shade quick toggle. However, if you try to turn off mobile data from either Android setting or the quick toggle, mobile data is STILL ACTIVE in the background. I can still browse websites without issues.

Logically, the next thing I tried was to set this:

mobile_data = 0
mobile_data0 = 0
mobile_data1 = 0
mobile_data2 = 0

However, mobile data is STILL enabled.

The trick is to click on the mobile data quick toggle multiple times (turning on and off). Do this at least twice (on, off, on, off) and this will fix the issue.

In other words, if you run into any issues trying to toggle mobile data on/off via the usual method (from quick toggle or android settings), then just make sure you toggle it on/off mutiple times.

Atm, I can make use of mobile_data0 = 1 as long as I make it wait 15 seconds. After 15 seconds, I'll try a HTTP GET action and if there's no data returned, then it'll speak a message to let me know that mobile data is bung and I'll need to manually fix it by toggling mobile data on/off and then run my Macrodroid macro again. If mobile_data0 = 1 is enabled, I'll also make it output a notification to let me know, so I can toggle it on/off to reset it.
 

dhj49er

Well-known member
I did some more troubleshooting and what I found is this:

When using mobile_data0 = 1, you have to set a wait time of 15 seconds before Android OS will know that mobile data turned on.

Once mobile data is enabled, it will show as enabled in the Android settings and in the notification shade quick toggle. However, if you try to turn off mobile data from either Android setting or the quick toggle, mobile data is STILL ACTIVE in the background. I can still browse websites without issues.

Logically, the next thing I tried was to set this:

mobile_data = 0
mobile_data0 = 0
mobile_data1 = 0
mobile_data2 = 0

However, mobile data is STILL enabled.

The trick is to click on the mobile data quick toggle multiple times (turning on and off). Do this at least twice (on, off, on, off) and this will fix the issue.

In other words, if you run into any issues trying to toggle mobile data on/off via the usual method (from quick toggle or android settings), then just make sure you toggle it on/off mutiple times.

Atm, I can make use of mobile_data0 = 1 as long as I make it wait 15 seconds. After 15 seconds, I'll try a HTTP GET action and if there's no data returned, then it'll speak a message to let me know that mobile data is bung and I'll need to manually fix it by toggling mobile data on/off and then run my Macrodroid macro again. If mobile_data0 = 1 is enabled, I'll also make it output a notification to let me know, so I can toggle it on/off to reset it.
On my (Oppo) phone neither data on/off actions or mobile_data settings work - all they do is toggle the status bar icon but don't turn on mobile data - when executed with WiFi disconnected.
If WiFi is connected the commands work and mobile data is on when WiFi disconnects.
Whenever the phone is connected to WiFi, I like to turn off mobile data. I keep WiFi connected all the time during the day. However, when I leave the WiFi area (eg leave home when I go out) I need mobile data to turn on when WiFi has disconnected.
I used the following work around. When connected to WiFi, I would use mobile data On action when the screen was turned off. If I left home WiFi would disconnect and mobile data would be on.
I used a timer to turn off mobile data if WiFi hadn't disconnected after 5 minutes, as I hadn't left home.
This works well but I now use a alternative method which uses UI to toggle the status bar icon. My Oppo phone has a system setting which allows access to the status bar from lock screen. So I can turn on mobile data when the screen is off. I prefer this approach as it eliminates the timer, but it does depend on your phone having the system setting to turn on/off the status bar access from the lock screen.
 

chaoscreater

Active member
On my (Oppo) phone neither data on/off actions or mobile_data settings work - all they do is toggle the status bar icon but don't turn on mobile data - when executed with WiFi disconnected.
If WiFi is connected the commands work and mobile data is on when WiFi disconnects.
Whenever the phone is connected to WiFi, I like to turn off mobile data. I keep WiFi connected all the time during the day. However, when I leave the WiFi area (eg leave home when I go out) I need mobile data to turn on when WiFi has disconnected.
I used the following work around. When connected to WiFi, I would use mobile data On action when the screen was turned off. If I left home WiFi would disconnect and mobile data would be on.
I used a timer to turn off mobile data if WiFi hadn't disconnected after 5 minutes, as I hadn't left home.
This works well but I now use a alternative method which uses UI to toggle the status bar icon. My Oppo phone has a system setting which allows access to the status bar from lock screen. So I can turn on mobile data when the screen is off. I prefer this approach as it eliminates the timer, but it does depend on your phone having the system setting to turn on/off the status bar access from the lock screen.

Would be nice if you could share that Oppo system setting you mentioned........but if it's specific to Oppo, I doubt it'll work for me. I used to have an Oppo and it was crap. So I went back to Xiaomi and am very happy with the phone.

On my phone, I can use mobile_data0 = 1 to turn on mobile data and my wifi doesn't need to be on for this to work. But as I mentioned in previous posts, this system setting has some quirks.

BTW, your workaround seems a bit odd. Couldn't you just have a trigger "if wifi is disconnected from home wifi SSID" (or any network), then turn on mobile data? Your wifi should still be on at that point, just that it has disconnected from your home network. You could even just have an action to turn wifi on right after it disconnects, then turn on mobile data, then turn off wifi. Much more accurate with less wakelock.

If you're going to turn on mobile data while your wifi is connected + screen is off, then you might as well just turn on mobile data the whole day. Unless you use your phone literally 24/7, your screen would be off most of the time. Your mobile data would be turned on and doing nothing during those times. It's bad for battery life and unnecessary, at least in my books. Turning on 3G/4G/5G drains a lot quicker (even when you're not actively using it) than leaving it off.

Assuming you're connected to wifi 90% of the time and your screen goes off at least 50% of the time, then your phone will be turning on mobile data probably 50% of the time, then after 5 mins it realizes it's still connected to wifi and turns off mobile data. Then it repeats the next time the screen goes off. That's pretty pointless.

For me, I just use a mix of bluetooth and NFC. If I leave home, I want wifi to be disabled automatically as I don't need it enabled and wasting battery. I don't need my phone to have data all the time when I leave home. It is only when I need to listen to Spotify or need Google Maps, then I would need mobile data. In those cases, I would be driving to work or driving somewhere and my phone would always be paired to my car's bluetooth. When car bluetooth is connected, prompt for choice. If correct choice is selected, launch spotify, turn on mobile data, do xyz.

Alternatively, I have NFC tags/stickers (they are cheap from Aliexpress or Ebay) and I stick them in my car. I'll just quickly wave my phone over the sticker and it'll run a bunch of actions for the macro that is specific to those stickers. Easy.
 

dhj49er

Well-known member
Would be nice if you could share that Oppo system setting you mentioned........but if it's specific to Oppo, I doubt it'll work for me. I used to have an Oppo and it was crap. So I went back to Xiaomi and am very happy with the phone.

On my phone, I can use mobile_data0 = 1 to turn on mobile data and my wifi doesn't need to be on for this to work. But as I mentioned in previous posts, this system setting has some quirks.

BTW, your workaround seems a bit odd. Couldn't you just have a trigger "if wifi is disconnected from home wifi SSID" (or any network), then turn on mobile data? Your wifi should still be on at that point, just that it has disconnected from your home network. You could even just have an action to turn wifi on right after it disconnects, then turn on mobile data, then turn off wifi. Much more accurate with less wakelock.

If you're going to turn on mobile data while your wifi is connected + screen is off, then you might as well just turn on mobile data the whole day. Unless you use your phone literally 24/7, your screen would be off most of the time. Your mobile data would be turned on and doing nothing during those times. It's bad for battery life and unnecessary, at least in my books. Turning on 3G/4G/5G drains a lot quicker (even when you're not actively using it) than leaving it off.

Assuming you're connected to wifi 90% of the time and your screen goes off at least 50% of the time, then your phone will be turning on mobile data probably 50% of the time, then after 5 mins it realizes it's still connected to wifi and turns off mobile data. Then it repeats the next time the screen goes off. That's pretty pointless.

For me, I just use a mix of bluetooth and NFC. If I leave home, I want wifi to be disabled automatically as I don't need it enabled and wasting battery. I don't need my phone to have data all the time when I leave home. It is only when I need to listen to Spotify or need Google Maps, then I would need mobile data. In those cases, I would be driving to work or driving somewhere and my phone would always be paired to my car's bluetooth. When car bluetooth is connected, prompt for choice. If correct choice is selected, launch spotify, turn on mobile data, do xyz.

Alternatively, I have NFC tags/stickers (they are cheap from Aliexpress or Ebay) and I stick them in my car. I'll just quickly wave my phone over the sticker and it'll run a bunch of actions for the macro that is specific to those stickers. Easy.
Your phone use case is significantly different from mine.
I need mobile data as soon as WiFi disconnects.
I leave home and often connect my phone to the car for Android Auto - which needs data for navigation.
Your mobile_data on is a faff and wouldn't work for me.
I've put the status bar on lock screen system setting in another thread. However, does your phone have a setting to manually control this feature? If not, there won't be a system setting.
I'm not sure I understand what you say about WiFi disconnecting but still being connected? No, the WiFi disconnects trigger means WiFi has disconnected. So what you suggested wouldn't work.
I'm happy with my UI method.
I find the status bar enabled on the lock screen to be very very useful.
I have another macro that can control WiFi in Airplane mode. I turn on Airplane mode at night (I turn off all radios to save battery). Should I need to use my phone at night I can turn on WiFi (screen on) and off (screen off, phone locked). Works a treat. I couldn't do this with the OnePlus or Samsung phones I've had previously. Kudos to Oppo.
 
In my case, mobile data is activated in the quick shortcuts tray(1), but it is not activated in the notification bar(2), so I don't have mobile data actually active, is there any way to solve it? I've already tried the ones mentioned above
 

Attachments

  • WhatsApp Image 2021-09-28 at 07.45.35.jpeg
    WhatsApp Image 2021-09-28 at 07.45.35.jpeg
    157.6 KB · Views: 11

dhj49er

Well-known member
In my case, mobile data is activated in the quick shortcuts tray(1), but it is not activated in the notification bar(2), so I don't have mobile data actually active, is there any way to solve it? I've already tried the ones mentioned above
I see that you have a dual SIM phone with both SIMs in use. Which SIM are you using for data? Is this SIM 1?
Does manually clicking on the data icon work ie show data on one of the radio icons?
 
Vejo que você tem um telefone Dual SIM com os dois SIMs em uso. Qual SIM você está usando para dados? Este é o SIM 1?
Clicar manualmente no ícone de dados funciona, ou seja, mostra dados em um dos ícones de rádio?
este é o SIM duplo, mas eu uso o SIM 1 para dados móveis e, quando clico manualmente, ele funciona perfeitamente
 

chaoscreater

Active member
Your phone use case is significantly different from mine.
I need mobile data as soon as WiFi disconnects.
I leave home and often connect my phone to the car for Android Auto - which needs data for navigation.
Your mobile_data on is a faff and wouldn't work for me.
I've put the status bar on lock screen system setting in another thread. However, does your phone have a setting to manually control this feature? If not, there won't be a system setting.
I'm not sure I understand what you say about WiFi disconnecting but still being connected? No, the WiFi disconnects trigger means WiFi has disconnected. So what you suggested wouldn't work.
I'm happy with my UI method.
I find the status bar enabled on the lock screen to be very very useful.
I have another macro that can control WiFi in Airplane mode. I turn on Airplane mode at night (I turn off all radios to save battery). Should I need to use my phone at night I can turn on WiFi (screen on) and off (screen off, phone locked). Works a treat. I couldn't do this with the OnePlus or Samsung phones I've had previously. Kudos to Oppo.

You're making this more complicated than it needs to be.....

There is literally a trigger in Macrodroid for when wifi is disconnected from a specific network, or any network.
There's a clear difference between wifi on and wifi enabled + connected to a SSID network.

Let's say your wifi is on and is connected to your home network. Now, walk out of your home for 200m. Your wifi will now be out of range from your home router and will therefore disconnect itself. Your wifi is still on, but NOT connected. This is a "wifi disconnected from network" event. This is NOT the same as the "wifi disabled" event, as that is turning off the wifi, not disconnection from a network.

When wifi is disconnected from network, turn on mobile data. Simple. No need to use any timers or whatever else. I have a macro that detects when wifi is disconnected from network and do XYZ when that happens.
 

dhj49er

Well-known member
You're making this more complicated than it needs to be.....

There is literally a trigger in Macrodroid for when wifi is disconnected from a specific network, or any network.
There's a clear difference between wifi on and wifi enabled + connected to a SSID network.

Let's say your wifi is on and is connected to your home network. Now, walk out of your home for 200m. Your wifi will now be out of range from your home router and will therefore disconnect itself. Your wifi is still on, but NOT connected. This is a "wifi disconnected from network" event. This is NOT the same as the "wifi disabled" event, as that is turning off the wifi, not disconnection from a network.

When wifi is disconnected from network, turn on mobile data. Simple. No need to use any timers or whatever else. I have a macro that detects when wifi is disconnected from network and do XYZ when that happens.
What you describe is what I used to do until mobile data on action stopped working.
Let me explain what happens on my phone
WiFi disabled turn mobile data on - data icon is on but data is not available.
WiFi enabled not connected to sssid turn mobile data on - data icon is on but data is not available
WiFi enabled & connected to ssid, turn on mobile data and move out of range of the ssid, WiFi disconnects from the ssid - data icon is on and data is available
WiFi enabled & connected to ssid, move out of range of ssid, WiFi disconnects from ssid, turn on mobile data - data icon is on but data is not available.
My use case is the last one.
So what you suggest will not work.
Mobile data stopped working for me from Android 11 and possibly Android 10.
I know mobile data action working or not is phone dependent.
What phone do you have and what version of Android is it using?
 
Looking for alternatives to solve this, I found a paleative solution, which would be:
Wifi enabled and connected to the network, when I left my house the wifi is disabled, mobile data is enabled, and I set my internet browser to open after 3 seconds (chrome).
it's instantaneous as soon as chrome opens the mobile data it actually starts to work.
 

dhj49er

Well-known member
Looking for alternatives to solve this, I found a paleative solution, which would be:
Wifi enabled and connected to the network, when I left my house the wifi is disabled, mobile data is enabled, and I set my internet browser to open after 3 seconds (chrome).
it's instantaneous as soon as chrome opens the mobile data it actually starts to work.
That seems a good alternative providing your phone is unlocked.
Unfortunately I need a solution that turns on mobile data when WiFi disconnects when the screen is off and phone is locked. I don't necessarily use my phone straight away but need data on for email, WhatsApp etc.
I have a really easy solution. I have a macro that toggles the status bar data icon.
 
That seems a good alternative providing your phone is unlocked.
Unfortunately I need a solution that turns on mobile data when WiFi disconnects when the screen is off and phone is locked. I don't necessarily use my phone straight away but need data on for email, WhatsApp etc.
I have a really easy solution. I have a macro that toggles the status bar data icon.

So friend, the way I explained mobile data is activated with the screen turned off and locked, test and give us feedback
 
I'm Brazilian, so I use the macros in Portuguese, but I'm sending the macro attached
 

Attachments

  • WhatsApp Image 2021-09-30 at 10.44.33.jpeg
    WhatsApp Image 2021-09-30 at 10.44.33.jpeg
    254.2 KB · Views: 24

Dm114

Well-known member
I'm Brazilian, so I use the macros in Portuguese, but I'm sending the macro attached
If you want to share an image of a macro, you should change language to English (in Settings) before making the image (or screenshot) and then go back to your System language. It'll be much easier for foreign users to understand your macro.
 

chaoscreater

Active member
What you describe is what I used to do until mobile data on action stopped working.
Let me explain what happens on my phone
WiFi disabled turn mobile data on - data icon is on but data is not available.
WiFi enabled not connected to sssid turn mobile data on - data icon is on but data is not available
WiFi enabled & connected to ssid, turn on mobile data and move out of range of the ssid, WiFi disconnects from the ssid - data icon is on and data is available
WiFi enabled & connected to ssid, move out of range of ssid, WiFi disconnects from ssid, turn on mobile data - data icon is on but data is not available.
My use case is the last one.
So what you suggest will not work.
Mobile data stopped working for me from Android 11 and possibly Android 10.
I know mobile data action working or not is phone dependent.
What phone do you have and what version of Android is it using?

You need to go back and read what I wrote in previous posts....

I was specifically addressing your comment on this:

I used a timer to turn off mobile data if WiFi hadn't disconnected after 5 minutes, as I hadn't left home.

My reply was:

BTW, your workaround seems a bit odd. Couldn't you just have a trigger "if wifi is disconnected from home wifi SSID" (or any network), then turn on mobile data?

What you described is simply an issue with your mobile data not turning on properly. However, that wasn't what I was discussing. I was discussing using the built-in "wifi disconnect" trigger to initiate an action to turn mobile data on. How you want to turn on mobile data is up to you, but there's no reason to use a timer.

And I'm u sing Xiaomi Redmi Note 9T running Android 11.
 

dhj49er

Well-known member
You need to go back and read what I wrote in previous posts....

I was specifically addressing your comment on this:



My reply was:



What you described is simply an issue with your mobile data not turning on properly. However, that wasn't what I was discussing. I was discussing using the built-in "wifi disconnect" trigger to initiate an action to turn mobile data on. How you want to turn on mobile data is up to you, but there's no reason to use a timer.

And I'm u sing Xiaomi Redmi Note 9T running Android 11.
No, I can't use WiFi disconnects as trigger to turn on mobile data, as it doesn't work. It only turns on the data icon.
As I have said I don't use the wait method now.
I now toggle the data icon using UI actions when WiFi disconnects - quick simple and works every time. The macro for this works with the screen on or off.
 
Top