Search code examples
androidandroid-activitybroadcastreceiverandroid-broadcast

Unregister broadcast receiver in the new activity


I want to ask, is it possible to unregister broadcast reciver in the new activity ?. For example, I click the button, register the receiver and then I go to the next activity. In new activity there is a button that I want to unregister this receiver and go back to main activity. Is there any way to implement it ?


Solution

  • It is possible using the Application class. Write the methods to register and un-register the receivers in the Applicaiton class and call them in respected Activities