Call startActivityForResult from Fragment doesn't call onActivityResult

前端 未结 1 1302
旧巷少年郎
旧巷少年郎 2020-12-30 05:30

I have a DialogActivity which is called from a Fragment for show a custom Dialog with two image buttons.

In DialogActivi

相关标签:
1条回答
  • 2020-12-30 05:59

    Activities that have the attribute noHistory=true will never have their onActivityResult() called when launching a new Activity via startActivityForResult(). As the documentation mentions, when the noHistory attribute is set to true, then finish() is called on the Activity when the user navigates away from the Activity.

    So, when startActivityForResult() is called, the Activity is navigated away from, causing its finish() to be called and making it never receive a call to onActivityResult(). If you remove the noHistory=true attribute from the Activity that's calling startActivityForResult(), then call finish() in your DialogActivity's onClick(), then you should still see the Activity that launched it, as well as receive a call to onActivityResult().

    0 讨论(0)
提交回复
热议问题