I have an Activity
that calls another Activity
, that calls some other Activities
.
I send to the last Activity
to get a result
The request code is not random. When using v4 support library fragments, fragment index is encoded in the top 16 bits of the request code and your request code is in the bottom 16 bits. The fragment index is later used to find the correct fragment to deliver the result to. Reference.
For example, 196614 is really 3 << 16 + 6 where 3 is the fragment index plus one and 6 is your request code.
Morale: Don't mix activity/fragment startActivityForResult()
and onActivityResult()
. When started from an activity, process the result in the activity. When started from a fragment, process the result in the fragment.