Quickly solve the problem that onactivityresult in fragment is not called

Fragment starts another activity through the startactivityforresult method. When it returns, the onactivityresult method is not called,

Solution steps:

1. In the activity to which the fragment belongs, override the onactivityresult method to ensure that super.onactivityresult is added

2. call startActivityForResult in Fragment and use startActivityForResult instead of getActivity ().StartActivityForResult.

There are two methods to capture hidden and displayed events in the fragment. The first is onhiddenchanged and the second is setuservisiblehint. The difference is:

Call hide show, onhiddenchanged will call

When fragment is used with viewpager, the setuservisiblehint method is called

The above article to quickly solve the problem that onactivityresult in fragment is not called is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>