So, I'm facing a strange behavior. I'm implementing MVP design pattern in my app. I have 2 activities, A and B. The presenter of activity A is listening to a socket connection to the server. In the activity's onDestroy() method, I call a method to unregister the presenter from the socket helper class.
In case of a certain message "TYPE X" from the socket, I start a new activity B. The onDestroy() method is called normally, and the socket listener is unregistered.
Here's the weird part. When receiving a message of the same TYPE "X", activity A is recreated and activity B is restarted, repeating the whole cycle again.
The activity A:
@Override
protected void onDestroy() {
mainActivityPresenter.terminate();
// some code
super.onDestroy();
}
The presenter:
@Override
public void terminate() {
socketHelper.unregisterListener(socketListener);
}
Does anyone have an explanation for this behavior?
Aucun commentaire:
Enregistrer un commentaire