Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
onActivityResult 不能与片段一起使用。如何在扩展片段而不是片段活动的类中调用 onActivityResult。片段中是否还有其他类似于 onActivityResult 的方法?
1.确保你的代码是这样的:
startActivityForResult(intent,req);
而不是这个:
getActivity().startActivityForResult(intent,req);
2. 确保实现 Fragment 的 onActivityResult:
super.onActivityResult(requestCode, resultCode, data);