When the activity/fragment that calls the startForResult gets destroyed and the called Intent finish:
1- The ActivityResultFragment#onActivityResult gets called but the listener is null (because the fragment has been recreated), which results in the fragment not being removed from the fragment manager.
2- The onResume is called and the started intent is called again.
Solution: Avoid calling the startActivityForResult if it has already been called by removing the Fragment when onActivityResult is called even if the listener is null.
Drawbacks: When the calling activity is destroyed after calling startForResult, the Intent result cannot be propagated to it. I couldn't find a proper solution to get it works in this case.
Fix issue #5
When the activity/fragment that calls the
startForResult
gets destroyed and the called Intent finish:1- The
ActivityResultFragment#onActivityResult
gets called but thelistener
is null (because the fragment has been recreated), which results in the fragment not being removed from the fragment manager.2- The
onResume
is called and the started intent is called again.Solution: Avoid calling the startActivityForResult if it has already been called by removing the Fragment when onActivityResult is called even if the
listener
is null.Drawbacks: When the calling activity is destroyed after calling
startForResult
, the Intent result cannot be propagated to it. I couldn't find a proper solution to get it works in this case.