Problem: When we start a fragment from an activity and then instantiate some sub-fragment in this fragment, there is a return in the child fragment to initiate another activity, That is, through the Startactivityforresult way to start, this time caused by the phenomenon will be, son fragment receive Onactivityresult, If the Getactivity.startactivityforresult is initiated in the sub-fragment, only the activity receives Onactivityresult, if the Getparentfragment.startactivit Yforresult mode is started, then only the parent fragment can receive (at this time the activity can also receive), but in any case the child fragment receive Onactivityresult.
Workaround: In the activity of the Onactivityresult method, call the startup of the Fragment Onactivityresult (Requestcode, ResultCode, data); Again at the start of the fragment call sub Fragmentonactivityresult (Requestcode, ResultCode, data); This causes inconsistencies in the requestcode and invocations that are obtained in Onactivityresult (), and the workaround is to use getparentfragment.getactivity () instead in the child fragment. Startactivityforresult () is normal.
Questions about Android Fragment Onactivityresult