If you would like to receive the events only when your activity is visible,
onPause is the best place to turn off the receiver. If you’d like to listen for as long as your activity is running, even if it’s not visible, you’ll want to unregister in
onDestroy. Wherever you decide to stop listening, simply call
unregisterReceiver (a method implemented by your superclass) and pass in the
Unregistering the broadcast receiver.
Share this highlighthttp://www.safaribooksonline.com/a/beginning-android-programming/341095/