Unregistering a statically defined BroadcastReceiver in code?

by Akbur » Sun, 02 Nov 2008 23:22:11 GMT


Sponsored Links
 Dear all,

I've registered my BroadcastReceiver in my application manifest like
this:

    <application android:icon="@drawable/icon" android:label="@string/
app_name" android:debuggable="true">
        <receiver android:enabled="true" android:name=".SMSReceiver">
            <intent-filter>
                <action
android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>
    </application>

Suppose I wish to make an Activity which is able to unregister this
BroadcastReceiver.  I know there is a method called
unregisterReceiver(BroadcastReceiver receiver) however I am not sure
how I can pass the correct receiver instance to it?  Has any one done
this?  If so, would you care to share? :-)

Thanks!
Akbur

--~--~---------~--~----~------------~-------~--~----~



Unregistering a statically defined BroadcastReceiver in code?

by Jason Parekh » Mon, 03 Nov 2008 02:32:19 GMT


 Hi Akbur,

You can't "unregister" this receiver, but you can disable it.  Check out
PackageManager.setComponentEnabledSetting.

jason





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Unregistering a statically defined BroadcastReceiver in code?

by Akbur » Mon, 03 Nov 2008 19:14:47 GMT


 This looks as though it should do the trick.  Thanks Jason. :-)

Akbur




--~--~---------~--~----~------------~-------~--~----~