Latest update on enabling and disabling mobile data programmatically [duplicate]

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);
   }

Leave a Comment