Refactored handling an activity result to use a map (SparseArray).