To enable:
val component = ComponentName(this, MyBroadcastReceiver::class.java)
getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
Disable:
val component = ComponentName(this, MyBroadcastReceiver::class.java)
getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED , PackageManager.DONT_KILL_APP);