I had my class 'ABC' by extending the BroadcastReceiver
. But recently, I stumbled upon LocalBroadcastManager
.
here is my class declaration:
public class ABC extends BroadcastReceiver {}
So ABC is working as the listener and based on the action it would call another object.
I checked everywhere whether I can use LocalBroadcastManager
here without an activity. Actually class ABC is a core application class where it doesn't connect to any UI component.
Let me know how can I use LocalBroadcastManager
in my scenario.
I'm new to Android. Please help.
Maybe it's a bit late for the answer but I hope it'd be useful to you.
The first step is having a class which extends the application. This will be used to get the application context from outside an Activity.
Then add the following piece of code where you want to send the message to LocalBroadcasr
Finally, your class ABC will receive this intent as I show you next