I have the following problem: A fragment is getting me multiple times one broadcastRecivier:
onCreate my fragment:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Filtro de acciones que serán alertadas
IntentFilter filter = new IntentFilter("serv_connected");
filter.addAction("amigos_list");
// Crear un nuevo ResponseReceiver
receiver = new ResponseReceiverFragment();
// Registrar el receiver y su filtro
LocalBroadcastManager.getInstance(getContext()).registerReceiver(
receiver,
filter);
activity = ((SocialActivity) getActivity());
}
Here the broadcast, this within my fragment;
// Broadcast receiver que recibe las emisiones desde los servicios
private class ResponseReceiverFragment extends BroadcastReceiver {
// Sin instancias
private ResponseReceiverFragment() {
}
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case "serv_connected":
MyService aux = activity.getmService();
mUserList = MyService.xmpp.getOnlineUsers();
iconloader.hide();
break;
}
}
}
The fragment is within an activity containing 3 fragment with sliding tabs, nothing rare.
The problem is the following: When I enter and broadcast activity is triggered, the fragment receives correctly. Now, if I come back, (closing activity) and I open the activity again, the fragment receives twice the broadcast, and so on... etc etc.
What's going on? If you need more code, I can add.
Thank you