Android: How to Enable/Disable an Activity's Intent Filter Programmatically

Android: Can I enable/disable an activity's intent filter programmatically?

You can't do this directly, but you can create an activity alias in your AndroidManifest.xml with the intent filter in question, and then enable or disable the alias using PackageManager#setComponentEnabledSetting(), leaving your other intent filters in the main copy of the Activity so they won't be affected.

Disable ContentProvider by default and enable it programatically when needed

Thanks to Mike for figuring out the issue i was actually using COMPONENT_ENABLED_STATE_DISABLED and this should have been COMPONENT_ENABLED_STATE_ENABLED instead.

How to set broadcast receiver attributes programmatically?

You don't need to declare the BroadcastReceiver in the manifest if you are registering/unregistering programmatically. You only need to declare BroadcastReceivers in the manifest if you want them to be instantiated from external triggers (for example, on device boot, or from the Alarm Manager, etc.)



Related Topics



Leave a reply



Submit