You can disconnect the receiver with this code:
PackageManager pm = getPackageManager(); ComponentName compName = new ComponentName(getApplicationContext(), MyReceiver.class); pm.setComponentEnabledSetting( compName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
You can also use COMPONENT_ENABLED_STATE_ENABLED to turn on the receiver.
source share