1 package android.support.v4.app;
2 
3 import android.os.Bundle;
4 import android.os.Parcelable;
5 
6 import java.util.Arrays;
7 
8 class BundleUtil {
9     /**
10      * Get an array of Bundle objects from a parcelable array field in a bundle.
11      * Update the bundle to have a typed array so fetches in the future don't need
12      * to do an array copy.
13      */
getBundleArrayFromBundle(Bundle bundle, String key)14     public static Bundle[] getBundleArrayFromBundle(Bundle bundle, String key) {
15         Parcelable[] array = bundle.getParcelableArray(key);
16         if (array instanceof Bundle[] || array == null) {
17             return (Bundle[]) array;
18         }
19         Bundle[] typedArray = Arrays.copyOf(array, array.length,
20                 Bundle[].class);
21         bundle.putParcelableArray(key, typedArray);
22         return typedArray;
23     }
24 }
25