The Big Difference Between onPause() and onStop()
Shortly I had some unexpected behaviour while testing the android version of the airTracker. While debugging this issue I realized that there is a big difference between the onStop() and the onPause() method provided by the Activty class.
Short introduction to my bug issue. In the airTracker architecture I'm using a central class for requesting and receiving information from the server application. Only one activity can be assigned to the callback that is called if new information is received from the server application. So if a new Activity is started then the suspending Activity should unassign from the central class first, to prevent wrong behaviour in the process of switching from the supsending to new Activity. If the new Activity is getting started then the Activity should assign to the central class.
So I implemented this workflow by using onStop() and onResume() and realized that things go a little bit wrong. I falsely assumed that onResume() is the pendant to onStop(). So in my case the new Activity was started, the callback to the central class was assigned, some time later the onStop() method of the supsended Activity was called and removed the before set callback. That was the reason why the new active Activity didn't get any callbacks (sometimes) from the central class.
After moving the unassignment process from onStop() to onPause() everything works as aspected because onPause() is called before the Activity is being supsended.
The Activity state diagram shows the invokation order