質問

I have the following arrangement: CatActivity -> FragA -> FragB; where, FragA launches FragB using fragB.show(getChildFragmentManager(), "FragB”);.

FragB launches the gallery intent with

Intent img = new Intent(Intent.ACTION_GET_CONTENT);
img.setType("image/*");
startActivityForResult(Intent.createChooser(img, “Choose Photo”),PHOTO_REQUEST_CODE);

The problem is that the FragB’s onActivityResult is never reached. Does anyone know why?
FYI: neither CatActivity nor FragA implements its respective onActivityResult method.

役に立ちましたか?

解決

as far as my experience goes I've come to terms with the fact that onActivityResult is a complete mess.

For your particular situation I believe you should call startActivityForResult from fragA via getParent method in FragB. Then get the result in FragA and pass it onto the child fragment using getChildFragmentManager().getFragments().

I have followed this pattern for a FragmentTabHost where the individual tabs are child Fragments. There doesn't seem to be any default code to pass the activity result onto child fragments.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top