Hello,
i have two Activities A and B and one Service C. A starts B.
A and B:
- are binding and unbinding to the Service in
onStart()/onStop(). - are implementing a
Handler-Object that works with Messages. The Handler is needed, so if C is doing Work and the Result is there, it will give back a result or message to A or B. - are implementing a
ServiceConnection-Object. In the MethodonServiceConnectedfrom theServiceConnection-Object, the Handler will be given to the Service C. - If i leave A or B, the Handler for the Service will be set to Null in
onStop(). This is because the Activity is not active anymore, so it can not use the Result to do something for example showing a Dialog.
I have following Problem:
- If i start A and use a function from C everything works fine. Resultdialog is showing up.
- If i start B from A, also everything works fine. Resultdialog is showing up.
- Now if i press Back to go back to A, then C cannot contact A, cause the handler is still set to null. No Handler created Dialog is showing up.
I think it has to do something with the order of the lifecycle-methodcalls. onStart() for the new Activity is getting called before onStop() from the old activity.