Example usage for android.os Bundle Bundle

List of usage examples for android.os Bundle Bundle

Introduction

In this page you can find the example usage for android.os Bundle Bundle.

Prototype

public Bundle() 

Source Link

Document

Constructs a new, empty Bundle.

Usage

From source file:Main.java

public static Bundle pack(@NonNull final String key, @Nullable final Serializable serializable) {
    final Bundle bundle = new Bundle();
    return pack(bundle, key, serializable);
}

From source file:Main.java

public static Bundle createBundle(final String key, final Parcelable value) {
    final Bundle bundle = new Bundle();
    bundle.putParcelable(key, value);/* ww  w.  j av a 2 s. c o m*/
    return bundle;
}

From source file:Main.java

public static Bundle decodeUrl(String query) {
    Bundle ret = new Bundle();
    if (query != null) {
        String[] pairs = query.split("&");
        for (String pair : pairs) {
            String[] keyAndValues = pair.split("=");
            if (keyAndValues != null && keyAndValues.length == 2) {
                String key = keyAndValues[0];
                String value = keyAndValues[1];
                if (!isEmpty(key) && !isEmpty(value)) {
                    ret.putString(URLDecoder.decode(key), URLDecoder.decode(value));
                }//from  w ww.  j av a2 s . c o  m
            }
        }
    }
    return ret;
}

From source file:Main.java

public static void PrintLog(String text) {
    if (mHandler != null) {
        Message meg = new Message();
        Bundle bundel = new Bundle();
        bundel.putString("MESSAGE", text);
        meg.setData(bundel);/*w  w w .  j a  v  a  2  s  .  c  o m*/
        mHandler.sendMessage(meg);
    }
}

From source file:Main.java

/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 */// www  .  java2 s . c om
public static Bundle parseUrl(String url) {
    // hack to prevent MalformedURLException
    url = url.replace("weiboconnect", "http");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}

From source file:Main.java

public static Bundle decodeUrl(String s) {
    Bundle params = new Bundle();
    if (s != null) {
        String[] array = s.split("&");
        String[] arr$ = array;//from   w  w  w  .ja  v a  2s .com
        int len$ = array.length;

        for (int i$ = 0; i$ < len$; ++i$) {
            String parameter = arr$[i$];
            String[] v = parameter.split("=");
            if (v.length >= 2 && v[1] != null) {
                params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1]));
            } else {
                params.putString(URLDecoder.decode(v[0]), "");
            }
        }
    }

    return params;
}

From source file:Main.java

public static void sendMessageHandler(Handler handler, int what, String key, String value) {
    Message message = new Message();
    message.what = what;//from  w w w  .j a v a 2 s  .  c  om
    Bundle bundle = new Bundle();
    bundle.putString(key, value);
    message.setData(bundle);
    handler.sendMessage(message);
}

From source file:Main.java

public static Bundle bundleCalendar(Calendar cal, long minDate) {
    Bundle args = new Bundle();
    if (cal == null)
        cal = Calendar.getInstance(Locale.getDefault());
    ;/*from   w ww .ja  v  a  2  s.  co m*/
    args.putInt("year", cal.get(Calendar.YEAR));
    args.putInt("month", cal.get(Calendar.MONTH));
    args.putInt("day", cal.get(Calendar.DAY_OF_MONTH));
    args.putInt("hour", cal.get(Calendar.HOUR_OF_DAY));
    args.putInt("minute", cal.get(Calendar.MINUTE));
    args.putLong("minDate", minDate);
    return args;
}

From source file:Main.java

public static Bundle decodeUrl(String s) {
    Bundle params = new Bundle();
    if (s != null) {
        String array[] = s.split("&");
        for (String parameter : array) {
            String v[] = parameter.split("=");
            if (v.length == 2) {
                params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1]));
            }// w ww . j  a v  a2  s.  c  om
        }
    }
    return params;
}

From source file:Main.java

public static Bundle decodeUrl(String s) {
    Bundle params = new Bundle();
    if (s != null) {
        params.putString("url", s);
        String array[] = s.split("&");
        for (String parameter : array) {
            String v[] = parameter.split("=");
            if (v.length > 1)
                params.putString(v[0], URLDecoder.decode(v[1]));
        }// ww  w  . j a  va  2  s  .  c o m
    }
    return params;
}