How to unregister multiple Broadcast receiver which are in different classes at a time?

43
December 06, 2018, at 4:10 PM

i want to unregister some broadcast receivers with single click.here is the flow.. lets say in Activity A i have below broadcast receivers.

    public BroadcastReceiver upload = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
        }
    };
 public BroadcastReceiver download = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
        }
    };

and in Activity B i have below broadcast receivers

 public BroadcastReceiver wifi = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
        }
    };
 public BroadcastReceiver data = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
        }
    };

my problem is i want to unregister all these BroadcastReceiver from Activity C with a button click. How can i do that? and how can i check is receiver is registered or not..?

Answer 1
  1. Create an Interface in your Activity C with a method unresisterRegisters()
  2. Implement this Interface In Activity A and B. Overrrid the method and write code for unregistere Receivers
  3. create object of A and B in Activity C inside OnButton click and call unresisterRegisters() method with both methods.

I hope this will help You.

READ ALSO
Android App crashes only on specific devices

Android App crashes only on specific devices

I've recently released my first app on Google Play and many users installed it alreadyThere seem to be no problems so far, except 2 different errors reported by Google Play Console

40
Button swipe from center to left and right

Button swipe from center to left and right

I am crating one task management application in AndroidIn that one I have to create sign in/sign out option

39
Adjust cropper instead of image zoom react native image crop picker

Adjust cropper instead of image zoom react native image crop picker

I am trying to adjust the cropper instead of zoom in and zoom out of image

44
how can we create android application for existing website…what methods can be used

how can we create android application for existing website…what methods can be used

I am trying to build an app for my site but I don't have any idea how to startI want the app to update the details for the user in the website also when user update in app like account details should web view or any other method

21