Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable/Enable mobile data on Android L with root access

I am writing a little app that only I will use and I want to pragmatically enable / disable my mobile data on a rooted android 4.5 device (I am running a custom Android L for Nexus 4).

I have looked for a while and I found the methods with reflection that worked until android 4.3. I have also seen the method from this post Toggle mobile data programmatically on Android 4.4.2 but this requires cyanogenmod.

From what I can find on the internet this is impossible for non-root apps but my question is:

is there something I can do with my root privileges to accomplish this?

like image 779
Nactive Avatar asked Aug 23 '14 21:08

Nactive


1 Answers

I noticed that the service call method does not work consistently on all devices. The number to be used in it varied from device to device.

I have found the following solution which works without any issue across all ROOTED devices.

Simply execute the following via su

To enable mobile data

svc data enable

To disable mobile data

svc data disable

It's as simple as that.

like image 161
A.J. Avatar answered Oct 15 '22 14:10

A.J.