Can anyone tell me a good approach to communicate from an Android Library Project to the App which uses this Library?
A little description: my library receives GCM notifications and forwards some of them to the App using this library. Right now I realized this with Intents send by the library and a BroadcastReceiver listening for that intent in the App.
The problem: when I install 2 Apps with my application, both receive each others notifications. Anybody an idea?
Thanks in advance!
[Edit]
Here is some Code. I receive a GCM Notification in the library and forward it to the consuming App:
GCMIntentService:
@Override
protected void onHandleIntent(Intent intent) {
...
String notificationString = intent
.getStringExtra(GCMConstants.NOTIFICATION);
Intent broadIntent = new Intent(getResources().getString(
R.string.con_broadcast_gcm_notification));
broadIntent.putExtra("callback", notification.getCallback());
context.sendBroadcast(broadIntent);
...
}
and my BroadcastReceiver listens for con_broadcast_gcm_notification. It is registered in the manifest via Intent-Filter.
manifest.xml
...
<receiver android:name=".MyBroadcastReceiver" >
<intent-filter>
<action android:name="de.tuberlin.snet.gcm.notification" />
</intent-filter>
</receiver>
...