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