enable and disable broadcast receiver on button click

Posted by Akhil on Stack Overflow See other posts from Stack Overflow or by Akhil
Published on 2012-07-02T07:05:28Z Indexed on 2012/07/02 9:16 UTC
Read the original article Hit count: 210

Filed under:
|

i want to enable and disable broadcast receiver programatically.. The receiver shouldn't respond until it is programatically turned on.. i did dee some similar questions but non of the answers worked.. please help...

i tried this code but didn't work..

 PackageManager pm  = getApplicationContext().getPackageManager();
                        ComponentName componentName = new ComponentName("mypackage",
                                 ".receivername");

                        pm.setComponentEnabledSetting(componentName,
                                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                                PackageManager.DONT_KILL_APP);

© Stack Overflow or respective owner

Related posts about android

Related posts about broadcastreceiver