1

I am trying to enable/disable mobile data.

First, is it possible to implement this?

I am gone through the below link

How to disable Mobile Data on Android

Enable/disable data connection in android programmatically

But I am not getting the right way to implement this.

Getting InvocationTargetException and not able to add MODIFY_PHONE_STATE also in android manifest file as it is a system-only permission.

And from forum I came to know that it was deprecated after Gingerbread.

How do I need to implement this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
happy
  • 25
  • 5
  • did you added these permissions `uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" uses-permission android:name="android.permission.INTERNET" uses-permission android:name="android.permission.READ_PHONE_STATE"` – Shruti Aug 20 '14 at 06:21
  • 1
    MODIFY_PHONE_STATE cannot be used by third party apps. Check this documentation.http://developer.android.com/reference/android/Manifest.permission.html#MODIFY_PHONE_STATE – Shruti Aug 20 '14 at 06:26
  • Users would not like this behavior and its not possible without user interaction. – Arash GM Aug 20 '14 at 06:30
  • Thanks to Arash & shruti :) – happy Aug 20 '14 at 06:53

1 Answers1

2

I am trying to enable/disable mobile data.

First, is it possible to implement this?

No, that's not possible to achieve by third-party apps. Enabling/disabling mobile data should be done through system Settings app UI.

What you can do is to provide an instruction to end user on how to enable/disable mobile data and direct them to Settings app.

Community
  • 1
  • 1
ozbek
  • 20,955
  • 5
  • 61
  • 84