Example usage for android.os Bundle putString

List of usage examples for android.os Bundle putString

Introduction

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

Prototype

public void putString(@Nullable String key, @Nullable String value) 

Source Link

Document

Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:jp.mixi.android.sdk.util.UrlUtils.java

/**
 * ?Bundle???/* w ww  .ja va 2s.  com*/
 * 
 * @param data ?
 * @return Bundle
 */
private static Bundle decodeUrl(String data) {
    Bundle bundle = new Bundle();
    if (data != null) {
        String[] array = data.split(PARAM_SEPARATOR);
        for (String parameter : array) {
            String[] vals = parameter.split(EQUAL);
            if (vals.length == 2) {
                try {
                    bundle.putString(URLDecoder.decode(vals[0], HTTP.UTF_8),
                            URLDecoder.decode(vals[1], HTTP.UTF_8));
                } catch (UnsupportedEncodingException e) {
                    Log.e(TAG, e.getLocalizedMessage(), e);
                }
            }
        }
    }

    return bundle;
}

From source file:com.nononsenseapps.filepicker.sample.ftp.FtpPickerFragment.java

public static AbstractFilePickerFragment<FtpFile> newInstance(String startPath, int mode, boolean allowMultiple,
        boolean allowCreateDir, boolean allowExistingFile, boolean singleClick, String server, int port,
        String username, String password, String rootDir) {
    FtpPickerFragment fragment = new FtpPickerFragment();
    // Add arguments
    fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
    Bundle args = fragment.getArguments();

    // Add ftp related stuff
    args.putString(KEY_FTP_ROOTDIR, rootDir);
    args.putString(KEY_FTP_SERVER, server);
    args.putInt(KEY_FTP_PORT, port);/*w  w  w . j  a  v  a 2s. co m*/
    if (username != null && password != null) {
        args.putString(KEY_FTP_USERNAME, username);
        args.putString(KEY_FTP_PASSWORD, password);
    }

    return fragment;
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public static Bundle queryToBundle(List<SearchQuery> query) {
    if (query == null) {
        return null;
    }/*from www .java  2 s .  c o  m*/
    Bundle b = new Bundle();
    for (SearchQuery q : query) {
        try {
            b.putString(q.getSearchField().toJSON().toString(), q.getValue());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return b;
}

From source file:com.johan.vertretungsplan.VertretungFragment.java

public static Bundle createBundle(String title) {
    Bundle bundle = new Bundle();
    bundle.putString(EXTRA_TITLE, title);
    return bundle;
}

From source file:Main.java

/**
 * Concatenate two Parcelable Bundles containing String to form one Parcelable.<br>
 * The String message is stored via Bundle.putCharArray using {@link #BUNDLE_MESSAGE} as the key for the item.<br>
 *  /*from  w w w . j a v  a2 s .c  o m*/
 * @param one       Parcelable Bundle, containing String message
 * @param another    Parcelable Bundle, containing String message
 * @return Parcelable Bundle, including Parcelable one and another.
 * @see Bundle#putCharArray(String, char[])
 * @see Bundle#getCharArray(String)
 */
public static Parcelable assembleParcelMessage(Parcelable one, Parcelable another) {
    Bundle bundle = new Bundle();
    String message = "";
    String tmp = null;

    if (one != null) {
        tmp = ((Bundle) one).getString(BUNDLE_MESSAGE);
        if (tmp != null)
            message += tmp;
    }
    if (another != null) {
        tmp = ((Bundle) another).getString(BUNDLE_MESSAGE);
        if (tmp != null)
            message += tmp;
    }

    bundle.putString(BUNDLE_MESSAGE, message);
    bundle.setClassLoader(Bundle.class.getClassLoader());
    return bundle;
}

From source file:dk.kk.ibikecphlib.util.HttpUtils.java

public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        if (result.has("invalid_token")) {
            if (result.get("invalid_token").asBoolean()) {
                data.putBoolean("invalid_token", result.get("invalid_token").asBoolean());
                IBikeApplication.logoutWrongToken();
            }//from  ww  w.  j av  a 2s .  co  m
        }
        if (result != null && result.has("data")) {
            JsonNode dataNode = result.get("data");
            if (dataNode != null) {
                data.putInt("id", dataNode.get("id").asInt());
                data.putString("name", dataNode.get("name").asText());
                data.putString("email", dataNode.get("email").asText());
                if (dataNode.has("image_url"))
                    data.putString("image_url", dataNode.get("image_url").asText());
            }
        }
        ret.setData(data);
    }
    return ret;
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment.java

public static MainFragment newInstance(String text) {
    MainFragment mFragment = new MainFragment();
    Bundle mBundle = new Bundle();
    mBundle.putString(TEXT_FRAGMENT, text);
    mFragment.setArguments(mBundle);/*from  w w  w  . j  a  va  2s .  co m*/
    return mFragment;
}

From source file:air.com.snagfilms.cast.chromecast.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of
 * data in the {@link MediaInfo}. Since {@link MediaInfo} is not
 * {@link Parcelable}, one can use this container bundle to pass around from
 * one activity to another./*from w ww.j av  a  2s .  co m*/
 * 
 * @see <code>toMediaInfo()</code>
 * @param info
 * @return
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }

    return wrapper;
}

From source file:com.sunho.nating.fragments.DetailUnivFragment.java

/**
 * Create a new instance of DetailFragment.
 *
 * @param resourceId The resource ID of the Drawable image to show
 * @param title The title of the image/*w  w  w .  java  2s  .c  o  m*/
 * @param x The horizontal position of the grid item in pixel
 * @param y The vertical position of the grid item in pixel
 * @param width The width of the grid item in pixel
 * @param height The height of the grid item in pixel
 * @return a new instance of DetailFragment
 */
public static DetailUnivFragment newInstance(int resourceId, String title, int x, int y, int width, int height,
        int position, String locationLat, String locationLong) {
    myLocationLat = locationLat;
    myLocationLong = locationLong;
    intentPosition = position;
    DetailUnivFragment fragment = new DetailUnivFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_RESOURCE_ID, resourceId);
    args.putString(ARG_TITLE, title);
    args.putInt(ARG_X, x);
    args.putInt(ARG_Y, y);
    args.putInt(ARG_WIDTH, width);
    args.putInt(ARG_HEIGHT, height);
    fragment.setArguments(args);
    return fragment;
}

From source file:illab.nabal.util.ParameterHelper.java

/**
 * URL-decodes bundle parameters. /*from www.j  a  v a 2 s  .  c  o m*/
 * (x-www-form-urlencoded MIME content type)
 * 
 * @param queryString - query string parameters
 * @return Bundle
 */
public static Bundle decodeGetParams(String queryString) {

    Bundle params = new Bundle();

    if (queryString != null) {
        String[] array = queryString.split(AMPERSEND);

        for (String parameter : array) {
            String[] nvPair = parameter.split(EQUAL_MARK);
            try {
                params.putString(URLDecoder.decode(nvPair[0], UTF_8), URLDecoder.decode(nvPair[1], UTF_8));
            } catch (UnsupportedEncodingException e) {
                Log.e(TAG, e.getMessage());
                Log.e(TAG, "Failed to decode parameter : " + parameter);
            }
        }
    }
    return params;
}