onActivityResult is not being called in Fragment

后端 未结 30 2603
忘了有多久
忘了有多久 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:08

    Kotlin version (In your activity onActivityResult())

     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        //add following lines in your activity
        if(supportFragmentManager?.fragments!=null && supportFragmentManager?.fragments!!.size>0)
         for (i in 0..supportFragmentManager?.fragments!!.size-1) {
             val fragment= supportFragmentManager?.fragments!!.get(i)
             fragment.onActivityResult(requestCode, resultCode, data)
        }
     }
    

提交回复
热议问题