onActivityResult is not being called in Fragment

后端 未结 30 2712
忘了有多久
忘了有多久 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 04:53

    Kotlin version for those who use Android Navigation Component inspired in Mohit Mehta's answer

     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        supportFragmentManager.primaryNavigationFragment?.childFragmentManager?.fragments?.forEach { fragment ->
            fragment.onActivityResult(requestCode, resultCode, data)
        }
    }
    

提交回复
热议问题