5,600,725 Members 38,914 Now Online
XDA Developers Android and Mobile Development Forum

Toggle between WiFi and mobile data with tasker

Tip us?
 
CaracalSef
Old
#1  
CaracalSef's Avatar
Senior Member - OP
Thanks Meter 28
Posts: 295
Join Date: Oct 2010

 
DONATE TO ME
Default Toggle between WiFi and mobile data with tasker

Hello. Does anyone knows how to make a script for tasker which switch mobile data off if WiFi is connected and mobile data back on if there's no WiFi connection? For the last 3 or 4 hours I'm searching for this and can't find nothing.
Also, I want if there's no WiFi network, to switch WiFi off (so mobile data will be turned on).
I managed to do something, but it didn't worked. When I enabled the profiles with WiFi and mobile data both turned on, the mobile data turned off, then WiFi off, then mobile data on and so on, in a loop.
Handset: Sony Xperia Z
Rom: Official Stock 4.3
Recovery: XZDualRecovery
Kernel: XzKernel
Bootloader: Unlocked

 
juried
Old
#2  
Senior Member
Thanks Meter 63
Posts: 301
Join Date: Jan 2011
Wouldn't that be redundant? The os already does that.

Sent from my Nexus 7 using Tapatalk
The Following User Says Thank You to juried For This Useful Post: [ Click to Expand ]
 
CaracalSef
Old
#3  
CaracalSef's Avatar
Senior Member - OP
Thanks Meter 28
Posts: 295
Join Date: Oct 2010

 
DONATE TO ME
Thanks for the response. I know that if WiFi is connected, I'm using the internet from it, but mobile data is still active, right? Even if there's no traffic from mobile data, that's still on. Wouldn't that be a source of battery drain?
Handset: Sony Xperia Z
Rom: Official Stock 4.3
Recovery: XZDualRecovery
Kernel: XzKernel
Bootloader: Unlocked

 
sea2605
Old
(Last edited by sea2605; 31st December 2013 at 10:16 AM.)
#4  
sea2605's Avatar
Senior Member
Thanks Meter 119
Posts: 327
Join Date: Mar 2013
I set my data to turn off if my phone is connected for 5 minutes to a wifi. Important: set collision handling to 'abort existing task'.

Here you got pictures.

Edit:
if you are further interested in battery savings, you can read my thread "[BATTERY LIFE] How to get up to 7+h of screen-on-time"
Attached Thumbnails
Click image for larger version

Name:	uploadfromtaptalk1388484716512.jpg
Views:	345
Size:	87.9 KB
ID:	2485352   Click image for larger version

Name:	uploadfromtaptalk1388484728619.jpg
Views:	325
Size:	36.2 KB
ID:	2485353  
The Following User Says Thank You to sea2605 For This Useful Post: [ Click to Expand ]
 
RoberM
Old
(Last edited by RoberM; 31st December 2013 at 11:03 AM.)
#5  
Senior Member
Thanks Meter 79
Posts: 187
Join Date: Oct 2011
Location: ESPAŅA
This is absolutely redundant and unnecesary, when the phone connects to a wifi, it disables 3g/LTE data connection by itself. When you connect to a wifi you can see how the 3g/H/H+ icon above radio signal dissapears. The radio chip inside this phones can be used in Wifi mode or 3g/4g mode for data connection, but not both at a time. It is technically not possible.
 
EmeraldTimer
Old
#6  
EmeraldTimer's Avatar
Senior Member
Thanks Meter 45
Posts: 429
Join Date: Oct 2012


Accidentally sent from my Xperia Z using Tapatalk
Phone: Sony Xperia Z - C6603 | Kernel: Stock| ROM: Cyanogen 11 Nightly

The Following User Says Thank You to EmeraldTimer For This Useful Post: [ Click to Expand ]
 
sea2605
Old
#7  
sea2605's Avatar
Senior Member
Thanks Meter 119
Posts: 327
Join Date: Mar 2013
Quote:
Originally Posted by RoberM View Post
This is absolutely redundant and unnecesary, when the phone connects to a wifi, it disables 3g/LTE data connection by itself. When you connect to a wifi you can see how the 3g/H/H+ icon above radio signal dissapears. The radio chip inside this phones can be used in Wifi mode or 3g/4g mode for data connection, but not both at a time. It is technically not possible.
The moment you don't have wifi anylonger, the phone starts a fullburst search for wifi and 3G/4G networks (even if I don't want wifi/data at the moment). and this drains a hell of a lot of battery. then (if you go out e.g.) it finds a 3g/4g-connection which it tries to keep up (drains a lot battery) and in the same time searches for wifi-networks (also drains battery)... very inefficient use of battery

So I deactivate data after 5 mins automatically via tasker and turn it on manually when I need it (could also automate that, but I'm lazy). This way I circumvent all these battery drains

Additionally:
Under normal circumstances I'd also set wifi to "turn off if not connected" (in settings) and "optimize wifi for battery life", but I use a custom stock kernel that has issues with these settings so I need to leave wifi on all day
 
RoberM
Old
#8  
Senior Member
Thanks Meter 79
Posts: 187
Join Date: Oct 2011
Location: ESPAŅA
Quote:
Originally Posted by sea2605 View Post
The moment you don't have wifi anylonger, the phone starts a fullburst search for wifi and 3G/4G networks (even if I don't want wifi/data at the moment). and this drains a hell of a lot of battery. then (if you go out e.g.) it finds a 3g/4g-connection which it tries to keep up (drains a lot battery) and in the same time searches for wifi-networks (also drains battery)... very inefficient use of battery

So I deactivate data after 5 mins automatically via tasker and turn it on manually when I need it (could also automate that, but I'm lazy). This way I circumvent all these battery drains

Additionally:
Under normal circumstances I'd also set wifi to "turn off if not connected" (in settings) and "optimize wifi for battery life", but I use a custom stock kernel that has issues with these settings so I need to leave wifi on all day
Umm, ok... But this has nothing to do with what the OP asked, or what I said.
 
eryen
Old
#9  
Senior Member
Thanks Meter 113
Posts: 192
Join Date: Apr 2011
You may try e-robot from play store.

I have a command for that, after wifi disconnects, wait for 30 sec. If still wifi is not connected, automaticcaly disables wifi.

Same as for bluetooth. When i leave my phone in my desk and gone for a while, 60 sec later disable bt.

You can do what ever you want.

Sent from my C6603 using Tapatalk

The Following User Says Thank You to eryen For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes