onActivityResult is not being called in Fragment

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

    Another use case not already described in other answers:

    onActivityResult() declared in fragment is not invoked when using exception.startResolutionForResult():

    if (exception is ResolvableApiException) {
        exception.startResolutionForResult(activity!!, MY_REQUEST_CODE)
    }
    

    In this case replace exception.startResolutionForResult() with fragment's startIntentSenderForResult():

    if (exception is ResolvableApiException) {
        startIntentSenderForResult(exception.resolution.intentSender, MY_REQUEST_CODE, null, 0, 0, 0, null)
    }
    

提交回复
热议问题