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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With