Convert URL query string to Bundle - Android android.os

Android examples for android.os:Bundle

Description

Convert URL query string to Bundle

Demo Code

import android.os.Bundle;

public class Main{

    public static Bundle serialBundle(String params) {
        Bundle bundle = null;//from w  w w. ja  v  a 2s .  c o  m
        if (params != null && params.length() > 0) {
            bundle = new Bundle();
            String[] strs = params.split("&");
            String[] pairs = null;
            for (String str : strs) {
                pairs = str.split("=");
                if (pairs.length >= 2) {
                    bundle.putString(pairs[0], pairs[1]);
                }
            }
        }

        return bundle;
    }

}

Related Tutorials