It wont work on non-rooted phone as they added MODIFY_PHONE_STATE
permission check. This permission is only given to system or signature apps refer-here.
Check the code below from PhoneInterfaceManager:
@Override
public void setDataEnabled(boolean enable) {
enforceModifyPermission();
mPhone.setDataEnabled(enable);
}
private void enforceModifyPermission() {
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, null);
}
Related Contents:
- What permission do I need to access Internet from an Android application?
- How can I programmatically open the permission screen for a specific app on Android 6.0 (Marshmallow)?
- Exception ‘open failed: EACCES (Permission denied)’ on Android
- Android M – check runtime permission – how to determine if the user checked “Never ask again”?
- Permission Denial: startForeground requires android.permission.FOREGROUND_SERVICE
- Android marshmallow request permission?
- How to detect incoming calls, in an Android device?
- How to request permissions from a Service in Android Marshmallow
- WRITE_EXTERNAL_STORAGE when targeting Android 10
- If I have ACCESS_FINE_LOCATION already, can I omit ACCESS_COARSE_LOCATION?
- SYSTEM_ALERT_WINDOW – How to get this permission automatically on Android 6.0 and targetSdkVersion 23
- When should I use ACCESS_COARSE_LOCATION permission?
- List of Android permissions normal permissions and dangerous permissions in API 23? [duplicate]
- Listing permissions of Android application via adb
- android – “Exported receiver does not require permission” on receivers meant to receive from system services
- Android M Camera Intent + permission bug?
- Android 12 New Bluetooth Permissions
- How Do We Distinguish Never-Asked From Stop-Asking in Android M’s Runtime Permissions?
- Push notifications (GCM) permission at runtime?
- What’s the difference between access network state (ACCESS_NETWORK_STATE) and WIFI state (ACCESS_WIFI_STATE) permissions?
- How do I use adb grant or adb revoke?
- How to check MIUI autostart permission programmatically?
- SecurityException: not allowed to perform OP_READ_PHONE_STATE
- How to check Grants Permissions at Run-Time?
- Permission Denial while sharing file with FileProvider [duplicate]
- How to check if Android Permission is actually being used?
- Android 13 – READ_EXTERNAL_STORAGE_PERMISSION still usable
- USE_FINGERPRINT is deprecated in API level 28
- How does storage access change on Android 6?
- R cannot be resolved – Android error
- ADB Install Fails With INSTALL_FAILED_TEST_ONLY
- Resize a large bitmap file to scaled output file on Android
- Can’t connect Nexus 4 to adb: unauthorized
- How to update/refresh specific item in RecyclerView
- Disabling User dragging on BottomSheet
- How does the getView() method work when creating your own custom adapter?
- How to add button to notifications in android?
- How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?
- Moving and vanishing lines of code; trouble with Eclipse’s XML Editor
- TextInputLayout has no effect for giving hint programmatically in EditText
- How to draw an overlay on a SurfaceView used by Camera on Android?
- The Android emulator is out of view, how can I move it?
- hardcoded string “row three”, should use @string resource
- How to start shared element transition using Fragments?
- No resource found that matches the given name ‘@style/ Theme.Holo.Light.DarkActionBar’
- Android get bounding rectangle of a View
- How Do We Generate a Base64-Encoded SHA256 Hash of SubjectPublicKeyInfo of an X.509 Certificate, for Android N Certificate Pinning?
- Difference between debug and release apks
- How to get currency symbol by currency name?
- Job Scheduler vs Background Service