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

private static Bundle createNamePortBundle(String name, int port, TreeMap<String, ArrayList<String>> ips) {
    Bundle namePort = new Bundle();
    namePort.putString("name", name);
    namePort.putInt("port", port);
    if (ips != null) {
        ArrayList<String> ip = ips.get(name);
        Collections.shuffle(ip, new Random());
        namePort.putString("ip", ip.get(0));
    }//  w  w  w.j a v a 2s. c  om
    return namePort;
}

From source file:Main.java

public static <T> void putBundle(String key, T data, Intent intent) {
    Bundle bundle = new Bundle();

    try {/*from w w w.ja  v a 2 s . co m*/

        if (data instanceof Parcelable) {
            bundle.putParcelable(key, (Parcelable) data);
        } else if (data instanceof Serializable) {
            bundle.putSerializable(key, (Serializable) data);
        }
        intent.putExtras(bundle);

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void setServiceSync(String Authority, boolean on, android.accounts.Account account) {
    ContentResolver.setSyncAutomatically(account, Authority, on);
    if (on)/* w  w w  .  ja v a2  s . co m*/
        ContentResolver.requestSync(account, Authority, new Bundle());
}

From source file:Main.java

public static void sendMsg2Client(String sKey, String sObjParam, int iMsg) {
    Bundle extras = new Bundle();
    extras.putString(sKey, sObjParam);/*w w  w .ja  va 2  s.c o m*/
    sendMsg2Client(iMsg, 0, 0, extras);
}

From source file:Main.java

public static Message createMessage(int What, Parcelable parcelable) {
    Message message = new Message();
    message.what = What;// w w  w.j  a  va  2  s .  co m
    Bundle data = new Bundle();
    data.putParcelable(ARG_PARCELABLE, parcelable);
    message.setData(data);
    return message;
}

From source file:Main.java

public static void start(Context context, Class<? extends Activity> clazz, String arg1) {
    Intent intent = new Intent(context, clazz);
    Bundle bundle = new Bundle();
    bundle.putString(ARG_1, arg1);//from www .j av  a 2s  .co  m
    intent.putExtras(bundle);
    context.startActivity(intent);
}

From source file:Main.java

/**
 * @param url// w w w  .  j a va 2  s . c o m
 * @return bundle that contains key-value entries of the url query and fragment.
 */
public static final Bundle getUrlParameters(final String url) {
    final Bundle bundle = new Bundle();
    final String[] separated = url.split("\\?");
    if (separated.length > 1) {
        final String query = separated[1];
        final String[] params = query.split("[&#]");
        for (final String param : params) {
            final String[] keyvalue = param.split("=");
            final String key = URLDecoder.decode(keyvalue[0]);
            String value = null;
            if (keyvalue.length > 1) {
                value = URLDecoder.decode(keyvalue[1]);
            }
            bundle.putString(key, value);
        }
    }
    return bundle;
}

From source file:Main.java

private static Bundle getArguments(Fragment fragment) {
    return (fragment.getArguments() == null) ? new Bundle() : fragment.getArguments();
}

From source file:Main.java

public static void ActivitySkipWithObject(Context context, Class<?> toClass, String key, Serializable obj) {
    Intent intent = new Intent();
    intent.setClass(context, toClass);/*from   w  ww  .java  2s  .  c  om*/
    Bundle bundle = new Bundle();
    bundle.putSerializable(key, obj);
    intent.putExtras(bundle);
    //        int id =((IdObj)bundle.getSerializable("  ")).getId();
    context.startActivity(intent);
}

From source file:Main.java

public static Intent mapToIntent(Context context, Class<?> clazz, Map<String, Object> map) {
    Intent intent = new Intent(context, clazz);
    Bundle bundle = new Bundle();
    if (map != null && map.size() > 0) {
        for (String key : map.keySet()) {
            if (map.get(key) instanceof String) {
                bundle.putString(key, (String) map.get(key));
            } else if (map.get(key) instanceof Integer) {
                bundle.putInt(key, (Integer) map.get(key));
            } else if (map.get(key) instanceof Boolean) {
                bundle.putBoolean(key, (Boolean) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Long) {
                bundle.putLong(key, (Long) map.get(key));
            } else if (map.get(key) instanceof Float) {
                bundle.putFloat(key, (Float) map.get(key));
            } else if (map.get(key) instanceof Double) {
                bundle.putDouble(key, (Double) map.get(key));
            } else if (map.get(key) instanceof Serializable) {
                bundle.putSerializable(key, (Serializable) map.get(key));
            } else if (map.get(key) instanceof Parcelable) {
                bundle.putParcelable(key, (Parcelable) map.get(key));
            }/* ww w .  java2  s .com*/
        }
    }
    return intent.putExtras(bundle);
}