mutate Bundle - Android Android OS

Android examples for Android OS:Bundle

Description

mutate Bundle

Demo Code


//package com.book2s;
import android.os.Bundle;
import android.os.Parcel;

public class Main {
    public static Bundle mutate(Bundle bundle) {

        if (bundle == null) {
            return null;
        }/*from w  w w  . j av  a  2 s  .c  om*/

        final Parcel in = Parcel.obtain();
        in.writeBundle(bundle);
        final byte[] bytes = in.marshall();

        final Parcel out = Parcel.obtain();
        out.unmarshall(bytes, 0, bytes.length);
        out.setDataPosition(0);

        try {
            return out.readBundle();
        } finally {
            in.recycle();
            out.recycle();
        }
    }
}

Related Tutorials