Android examples for android.os:Bundle
Convert Persistable Bundle To Bundle
import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.os.PersistableBundle; import java.util.Set; public class Main{ @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) public static Bundle persistableBundleToBundle( PersistableBundle persistableBundle) { Set<String> keySet = persistableBundle.keySet(); Bundle bundle = new Bundle(); for (String key : keySet) { Object value = persistableBundle.get(key); if (value instanceof Boolean) { bundle.putBoolean(key, (boolean) value); } else if (value instanceof Integer) { bundle.putInt(key, (int) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof String[]) { bundle.putStringArray(key, (String[]) value); } else if (value instanceof PersistableBundle) { Bundle innerBundle = persistableBundleToBundle((PersistableBundle) value); bundle.putBundle(key, innerBundle); }/*from w w w . ja va 2 s . c o m*/ } return bundle; } }