位置: 编程技术 - 正文
推荐整理分享Fragment中调用onActivityForResult处理(fragment的context),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:fragment如何调用activity中的方法,fragment not attach context,fragment调用activity方法,fragment怎么用,fragment add replace,fragment调用activity方法,fragment调用另一个fragment,fragment onclick,内容如对您有帮助,希望把文章链接给更多的朋友!
The activity hosting this fragment has its onActivityResult called when the camera activity returns
My fragment starts an activity for result with the intent sent for the camera to take a picture. The picture application loads fine, takes a picture, and returns. The onActivityResult however is never hit. I’ve set break points but nothing is triggered. Can a fragment have onActivityResult? I’d think so since its a provided function. Thoughts on why this isn’t being triggered?
So I figured out the problem and will post the answer for anyone else experiencing this issue. The hosting activity overrode the onActivityResult but did not make a call to super.onActivityResult for unhandled result codes. Apparently even though the fragment is the one making the startActivityForResult call, the activity gets the first shot at handling the result. This makes sense when you consider the modularity of fragments. Once I implemented super.onActivityResult for all unhandled results, the fragment got a shot at handling the result.
And also from @siqing answer
To get the result in your fragment make sure you call : startActivityForResult(intent,);instead of getActivity().startActivityForResult(intent,); inside your fragment.
解决方法就是: 在Fragment中直接调用startActivityForResult()方法, 而不是调用 getActivity().startActivityForResult()。
stackoverflow
Android Volley框架的使用(二) 在上一篇文章中介绍了volley框架的特性,如何将volley.jar引入我们的项目,以及volley框架中最常用的两个类RequestQueueRequest基本的使用方法;这篇介绍Volley
android 一个集合问题导致不得不说的故事 啥也不说,先看图,然后给你讲需求!技能中只能添加三项,如果选择超过三个就给提示,选中的可以再次点击就是删除,这个肯定不难,但是做着发现一个问题,
Activity的四种启动模式和onNewIntent() 转自:
标签: fragment的context
本文链接地址:https://www.jiuchutong.com/biancheng/374516.html 转载请保留说明!上一篇:JavaScript文件处理:文件读取(js的文件操作)
友情链接: 武汉网站建设