Convert Map<String, Serializable> To Bundle - Android android.os

Android examples for android.os:Bundle

Description

Convert Map<String, Serializable> To Bundle

Demo Code

import android.os.Bundle;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class Main{

    public static Bundle mapToBundle(Map<String, Serializable> map) {
        Bundle result = new Bundle();
        if (map == null)
            return result;

        for (String key : map.keySet()) {
            result.putSerializable(key, map.get(key));
        }/*from   w  w  w  .jav a  2 s . c  om*/
        return result;
    }

}

Related Tutorials