To follow up on @MrSnowflake answer with a code example.
This is the XABBER now open source Application
class. The Application
class is centralising and coordinating Listeners
and ManagerInterfaces and more. Managers of all sorts are dynamically loaded. Activity´s
started in the Xabber will report in what type of Listener
they are. And when a Service
start it report in to the Application
class as started. Now to send a message to an Activity
all you have to do is make your Activity
become a listener
of what type you need. In the OnStart()
OnPause()
register/unreg. The Service
can ask the Application
class for just that listener
it need to speak to and if it's there then the Activity is ready to receive.
Going through the Application
class you'll see there's a loot more going on then this.