I have a main app, we call it 'app' and then sub modules called 'module1' and 'module2'. These modules are dependencies of the 'app'. The 'app' starts 'module1', which does its job and once done, it broadcasts a message, which should be picked up by the 'app' so that it could continue its flow. However, I don't seem to be successfully receiving it in the 'app'.
I am wondering, is it possible at all to send broadcast messages from submodules?
The modules are supposed to remain as much independent of the main app as possible so that could be used with other apps too, like plugins. That is why I am not adding anything in the main app's manifest related to the modules. Modules have their own manifests.
Broadcasts work fine within a module.
The code is pretty straight forward:
public class MyReceiver extends BroadcastReceiver {
mFilter = new IntentFilter("com.myapp.main.CUSTOM_INTENT");
mReceiver = new MyReceiver();
@Override
public void onReceive(Context context, Intent intent) {
Log.i(Constants.TAG, "receiver worked");
}
// constructor
public MyReceiver(){
}
}
And in the manifest:
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="com.myapp.main.CUSTOM_INTENT" />
</intent-filter>
</receiver>
And in the submodule:
Intent intent = new Intent("com.myapp.main.CUSTOM_INTENT");
intent.putExtra("value", 0);
sendBroadcast(intent);