onActivityResult is not being called in Fragment

后端 未结 30 2717
忘了有多久
忘了有多久 2020-11-21 04:28

The activity hosting this fragment has its onActivityResult called when the camera activity returns.

My fragment starts an activity for a result with th

30条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-21 05:12

    In case you don't know fragments in your activity just enumerate them all and send activity result arguments:

    // In your activity
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        for (Fragment fragment : getSupportFragmentManager().getFragments()) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }
    

提交回复
热议问题