All Projects → shamanland → nested-fragment-issue

shamanland / nested-fragment-issue

Licence: other
No description, website, or topics provided.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

onActivityResult not being called in Fragment

Read more details in original post.

Description

FragmentActivity replace requestCode by modified one. After that, when onActivityResult() will be invoked, FragmentActivity parse higher 16 bits and restore index of original Fragment. Look at this scheme:

enter image description here

If you have few fragments at the root level there is no problems. But if you have nested fragments, for example Fragment with few tabs inside ViewPager, you guaranteed will face with a problem (or already faced it).

Because only one index is stored inside requestCode. That is index of Fragment inside it's FragmentManager. When we using nested fragments, there are child FragmentManager, which has own list of Fragments. So, it's necessary to save whole chain of indices, starting from root FragmentManager.

enter image description here

Solution

Compile this project and look at the CommonActivity.java.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].