简体   繁体   中英

Android - How to listen to broadcast receiver unregistered?

I have an activity A.java which sends a broadcast and needs to wait for this broadcast unregistered then do something else. This broadcast receiver will invoke another activity B.java and only unregister the broadcast receiver when the activity is finished.

So my question is how to make A.java listen to the broadcastReceiver unregistered?

To be more specific, it's A.java in app A and B.java in app B. I can't figure out a way to communicate between apps but broadcast. Does anyone have better idea?

Thanks!!

I suggest you rethink your app flow. When Activity A sends a local broadcast, Activity B can listen and send back another broadcast after the task which it is supposed to do is done. You don't have to listen to Broadcast Receivers being unregistered, as you should be unregistering them in a lifecycle teardown event (such as onStop).

Wrong appraoch. You cannot be triggered on "unregister" of a receiver.

You can communicate between activities iun a single task either by calling startActivityForResult() or startActivity() and passing data in Intent , or by sending data in broadcast Intent s. Leave your receivers registered and listening, and send as many broadcast Intent s as necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM