I have a NetworkReceiver class that extends BroadcastReceiver. Its onReceive() method is called when there is a connectivity change and, if there is a connection, my SyncIntentService is called which exchanges data with the server.
When completed, SyncIntentService sends a local broadcast via LocalBroadcastManager, but I am not sure of the best way to set up my NetworkReceiver class to listen for these local broadcasts.
The issue is that there does not seem to be a Context object available in NetworkReceiver to pass to LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);.
Actually, there is the Context object that is passed in to NetworkReceiver's onReceive() method, but I'm not sure if it would the best practice to register a LocalBroadcastManager receiver there.
Is there a better way?
NB - This answer explains why you can't register a LocalBroadcastManager receiver in the manifest, so that obviously isn't an option.