Search code examples
androidcallbackbroadcastreceiverlocationmanager

broadCastReceivers Vs CallBackListeners


After I worked with the BroadCastreceivers of the Networks, a question occured to my mind, since the broadCastReceivers almost work as if they listen to any system changes and notify the user about these changes, only if, the user has registered to listen to these system change events using RegisterReceiver(). The question is

What is the difference then between broadCastReceiver used in Connectivity Manager and the CallbackListeners used in LocationManager, or in other words, why the LocationManager does not use `broadCastReceiver and vice versa?


Solution

  • CallbackListener will be used, when you’re code initiates an asynchronous call and awaits an answer to it.

    broadCastReceiver will be used, when something can happen unexpectedly and at anytime