I create an application as below:
Main activity includes FragmentTabHost
which includes two ContainerFragments
which include two Fragments separately.
Now I startActivityForResult
from UserFragment
, but onActivityResult
in UserFragment
cannot be called! What's wrong? How to resolve?
The project in https://github.com/VictorS-Zhao/TabHostAndNestedFragment.
Thanks in advance!
Supplement:
This is a strange behavior, the 1st nested fragment Community Fragment's onActivityResult
can be called every time, but the 2nd nested fragment User Fragment's cannot be called. When startActivityForResult
from UserFragment
, but the onActivityResult
in CommunityFragment
is called.
Solution:
Finally I found solution in onActivityResult() not called in new nested fragment API
According to this answer, should override onActivityResult
in ContainerFragment
, and use getParentFragment().startActivityForResult
in UserFragment
. That's nice!