且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我会收到错误的请求,code?

更新时间:2022-03-10 22:32:58

这是一个愚蠢的问题。但对于别人谁运行到同样的问题我张贴的答案。

It was a stupid question. But for anyone else who runs into the same "problem" I'm posting the answer.

它的发生,因为如果你使用 startActivityForResult 从对话框,在 onActivityResult 你请求code对话框。不从你的其它活动。如果你想获得正确的请求code,你应该使用 getActivity()。startActivityForResult(意向,要求code)在DialogFragment。

It's happens because if you use startActivityForResult from the dialog, in onActivityResult you get the requestCode of the dialog. Not from your another Activity. And if you want to get right requestCode, you should use getActivity().startActivityForResult(intent,requestCode) in DialogFragment.