• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Have Data turn on when GPS detects that I'm driving

bslow1

Lurker
I generally don't have my data on by default (limited data plan), but I would like to have Data turn on when the phone detects that I'm driving in my car (through GPS presumably). My GPS is always on, so if there is a way to have Tasker turn on Data based on GPS results, then it should work.

I've tried using the variable %LOCSPD, which I thought would cause the Data to turn on when the GPS detected that I was traveling above a certain speed, but it didn't seem to work.

Any ideas would be helpful.

Thanks!

________________________________________________________________

UPDATE: Thanks to the brilliant minds at XDA-Developers, they created an app that allows you to toggle data on/off via Tasker despite Google's latest restrictions in Android 5.1. So that works now.

However, the Task that I'm trying to perform is still Hit/Miss. Sometimes it kicks in, sometimes it doesn't. And I can't tell whether or not its because %LOCSPD is an unreliable variable, or if the GPS isn't pinging often enough to register that I'm driving sometimes.

So if anyone has a better way of letting Tasker know that I'm driving in my car, I'd appreciate the input.
 
Last edited:
2 things:

- To debug, show a toast giving you the content of %LOCSPD to see that the speed is being updated as expected
- If you're on Lollipop+, you won't be able to switch the data on/off unless your phone is rooted
 
maybe you could have it sense a Cell Tower change?
I would presume that when you are at a fixed location, the cell site would not be switching all the time.

MacroDroid has a prebuilt macro to detect cell site changes, and I would presume that Tasker does also, but I have not looked at for that feature yet. The template supplied with MacroDroid saves the cell site info to Calendar. You could look at that for info on how they do it. This would have an inherent lag though depending on how far you drive and the coverage of a cell site.

and as mentioned, if the phone is NOT rooted yet, no app is able to turn data on/off in Lollipop.

* MacroDroid - Device Automation - Android Apps on Google Play
 
2 things:

- To debug, show a toast giving you the content of %LOCSPD to see that the speed is being updated as expected
- If you're on Lollipop+, you won't be able to switch the data on/off unless your phone is rooted

I'm going to try tinkering with %LOCSPD some more, but I wonder if I'm just setting it up wrong in Tasker. It should be fairly simple, right?

Variable Value - %LOCSPD > 7 m/s
-Task: Enable Mobile Data

But it just doesn't kick in. Maybe the relay of information is too delayed.... The phone is rooted, so I'm using Secure Settings to trigger the Data.

maybe you could have it sense a Cell Tower change?
I would presume that when you are at a fixed location, the cell site would not be switching all the time.

MacroDroid has a prebuilt macro to detect cell site changes, and I would presume that Tasker does also, but I have not looked at for that feature yet. The template supplied with MacroDroid saves the cell site info to Calendar. You could look at that for info on how they do it. This would have an inherent lag though depending on how far you drive and the coverage of a cell site.

and as mentioned, if the phone is NOT rooted yet, no app is able to turn data on/off in Lollipop.

* MacroDroid - Device Automation - Android Apps on Google Play

Thank you for the suggestion. Tasker does have Cell Tower identification, and in fact, I use that in another profile so that when I get home, it automatically enables my WiFi. In this case though, that won't work because I don't want Data on when I'm out walking, or just somewhere away from home. I only want it to turn itself on while I'm driving. I know it's picky, but I have limited data, and would like to be able to activate Google Maps or respond to texts with my voice, and that requires that data be on with my phone (Moto X).
 
So I discovered at least part of the problem -- When I try to test the Secure Settings task that enables data, I get an error message that says, "An Error occurred while executing action: Mobile Data".

Now, why would this be the case? The phone is rooted, and I don't see anything in Secure Settings that indicates I'm not allowed to enable that particular setting...
 
You've validated that you are root-ed ... correct?

... Thom

Yes, I'm definitely rooted. With Power Toggles, I am able to toggle data on and off. But anything I do with Tasker that involves toggling data through Secure Settings doesn't seem to work. I never tried to do anything with data before, so I never noticed. I had read that the issue might be that Android 5.1 prevents any data toggling, regardless of root. So maybe this is an issue I can't get around.
 
UPDATE: Thanks to the brilliant minds at XDA-Developers, they created an app that allows you to toggle data on/off via Tasker despite Google's latest restrictions in Android 5.1. So that works now.

However, the Task that I'm trying to perform is still Hit/Miss. Sometimes it kicks in, sometimes it doesn't. And I can't tell whether or not its because %LOCSPD is an unreliable variable, or if the GPS isn't pinging often enough to register that I'm driving sometimes.

So if anyone has a better way of letting Tasker know that I'm driving in my car, I'd appreciate the input.
 
UPDATE: Thanks to the brilliant minds at XDA-Developers, they created an app that allows you to toggle data on/off via Tasker despite Google's latest restrictions in Android 5.1. So that works now.

However, the Task that I'm trying to perform is still Hit/Miss. Sometimes it kicks in, sometimes it doesn't. And I can't tell whether or not its because %LOCSPD is an unreliable variable, or if the GPS isn't pinging often enough to register that I'm driving sometimes.

So if anyone has a better way of letting Tasker know that I'm driving in my car, I'd appreciate the input.

This work around that XDA has created, is it ONLY valid for Rooted Devices?

I would dearly love to get my stock Lollipop DATA switching on/off from MacroDroid again.
Or Tasker, whichever.
 
The explanation I read said Google removed the ability to grant permission to an app to toggle data mode. The answer to your question then is toot-only. The root-ed solution I posted is the one I found (but since I am not root-ed I did not test).

... Thom
 
This work around that XDA has created, is it ONLY valid for Rooted Devices?

I would dearly love to get my stock Lollipop DATA switching on/off from MacroDroid again.
Or Tasker, whichever.

Unfortunately, Yes, the phone would have to be rooted in order for it to work. If you ever do root your phone (or for anyone else that is interested), here is the link to the XDA page: http://forum.xda-developers.com/android/apps-games/app-toggle-data-5-0-widget-to-toggle-t2937936

Thom, I'm assuming that your solution is essentially what this app does for you once it's installed.
 
It is what was quoted at another source. It would have the advantage of simply being a shell command.

Perhaps someone who is root-ed can try it out. If they have Terminal installed they can just run the commands.

... Thom
 
Back
Top Bottom