Search code examples
androidbroadcastreceiver

Do I need to unregisterReceiver receiver in Android


I have broadcastReceiver defined in AndroidManifest.xml. Do I need to unregisterReceiver in activity's onDestroy and onPause? If yes, how to do it? Note that I didn't registerReceiver by code. Just defined in the AndroidManifest.xml. If required , then how to register again onStart and onResume?

  <receiver android:name="com.me.broadcastReceiver.test" >
        <intent-filter>
            <action android:name="abc" />
        </intent-filter>
    </receiver>

Solution

  • Nope, you do not need to unregister your receiver if it is declared in the manifest.

    You can still disable it if you want (for example check this answer).