Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.os.Bundle;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

public class Main {
    /**
     * Convert an Android bundle to a hashtable
     * @param bundle
     * @return
     */
    public static Hashtable bundleToHashtable(Bundle bundle) {
        Hashtable retVal = new Hashtable();
        Set<String> keys = bundle.keySet();
        Iterator<String> iterator = keys.iterator();

        String key;
        Object val;
        while (iterator.hasNext()) {
            key = iterator.next();
            val = bundle.get(key);
            if (val instanceof String) {
                retVal.put(key, val);
            } else if (val instanceof Integer) {
                retVal.put(key, val);
            }
        }

        return retVal;
    }
}