Define a different action string for each different operation. Set the action for each Intent
appropriately and check the action in onReceive of the BroadcastReceiver
.
/* when sending a broadcast */
Intent intent = new Intent("action_a");
context.sendBroadcast(intent);
/* in the BroadcastReceiver */
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
// intent didn't have an action
return;
}
if ("action_a".equals(action)) {
// do function A
} else if ("action_b".equals(action)) {
// do function B
} // and so on
}
In your AndroidManifest, add the following as a child element of the <receiver>
tag:
<intent-filter>
<action name="action_a" />
<action name="action_b" />
<!-- and so on -->
</intent-filter>