У меня есть 2 действия, назовите их A и B. Оба расширения: ServiceHelperAbstractActivity
, у которого есть BroadcastReceiver
, чтобы получать сообщения от Сервиса. Все отлично работает, когда я запускаю и даже тогда, когда я запускаю B, но если я стараюсь, чтобы перейти к от А до Б в А, BroadcastReceiver
по-прежнему зарегистрирован в B.Неверный BroadcastReceiver получает сообщение
public ServiceHelperAbstractBase(ServiceHelperListener listener,
Context context) {
mListener = listener;
mContext = context;
}
public BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String uuidString = intent
.getStringExtra(ServiceHelper.KEY_INTENT_UUID);
if (uuidString != null) {
UUID uuid = UUID.fromString(uuidString);
processRequestWithUuid(uuid);
}
mListener.onRequestDoneProcessing();
}
};
protected void onPause() {
ServiceHelper.disconnectReceiver(mContext, mReceiver);
}
protected void onResume() {
if (this.mRequestDataMap == null) {
this.mRequestDataMap = new HashMap<UUID, ServiceHelper.RequestData>();
}
List<UUID> toCall = new ArrayList<UUID>();
for (UUID uuid : this.mRequestDataMap.keySet()) {
toCall.add(uuid);
}
for (UUID uuid : toCall) {
processRequestWithUuid(uuid);
}
ServiceHelper.connectReceiver(mContext, mReceiver);
};
Любая помощь будет принята с благодарностью.