Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unregister broadcast receiver registered through manifest

Is it possible to unregister a BroadcastReceiver that has been registered through manifest? Also please let me know if it possible to ignore the BroadcastReceiver, without making any code changes, as this BroadcastReceiver is of no use to me now. Thanks.

like image 986
Mayur More Avatar asked Mar 25 '13 09:03

Mayur More


1 Answers

You can disable 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);

Also you can use COMPONENT_ENABLED_STATE_ENABLED to enable Receiver.

like image 156
Gabriele Mariotti Avatar answered Oct 20 '22 18:10

Gabriele Mariotti