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:com.ryan.ryanreader.fragments.CommentListingFragment.java

public static CommentListingFragment newInstance(final String parentPostIdAndType, final URI url,
        final UUID session, final CacheRequest.DownloadType downloadType) {

    final CommentListingFragment f = new CommentListingFragment();

    final Bundle bundle = new Bundle(4);

    bundle.putString("parentPostIdAndType", parentPostIdAndType);
    bundle.putString("url", url.toString());
    if (session != null)
        bundle.putString("session", session.toString());
    bundle.putString("downloadType", downloadType.name());

    f.setArguments(bundle);//  www  .j a  va2 s . c  o m

    return f;
}

From source file:by.zatta.pilight.connection.ConnectionService.java

/**
 * Send the data to all clients./*from  w w  w . j a  v a2s  .  c  o m*/
 * 
 * @param message
 *            The message to send.
 */
private static void sendMessageToUI(int what, String message) {
    // Log.v(TAG, "sent message called, clients attached: " + Integer.toString(mClients.size()));
    Iterator<Messenger> messengerIterator = mClients.iterator();
    while (messengerIterator.hasNext()) {
        Messenger messenger = messengerIterator.next();
        try {
            Bundle bundle = new Bundle();
            bundle.setClassLoader(aCtx.getClassLoader());
            switch (what) {
            case MSG_SET_STATUS:
                // Log.v(TAG, "setting status: " + message);
                bundle.putString("status", message);
                Message msg_string = Message.obtain(null, MSG_SET_STATUS);
                msg_string.setData(bundle);
                messenger.send(msg_string);
                break;
            case MSG_SET_BUNDLE:
                if (!mDevices.isEmpty()) {
                    // Log.v(TAG, "putting mDevices");
                    bundle.putParcelableArrayList("config", (ArrayList<? extends Parcelable>) mDevices);
                    Message msg = Message.obtain(null, MSG_SET_BUNDLE);
                    msg.setData(bundle);
                    messenger.send(msg);
                }
                break;
            }
        } catch (RemoteException e) {
            Log.w(TAG, "mClients.remove called");
            mClients.remove(messenger);
        }
    }
}

From source file:com.expertiseandroid.lib.sociallib.utils.Utils.java

/**
 * Transforms a map to a Bundle// ww w  . ja v  a2s  .  c o  m
 * @param map
 * @return a Bundle with the map's contents
 */
public static Bundle stringMapToBundle(Map<String, String> map) {
    Bundle b = new Bundle();
    for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) {
        String key = it.next();
        b.putString(key, map.get(key));
    }
    return b;
}

From source file:com.heraldapp.share.facebook.Util.java

/**
 * Connect to an HTTP URL and return the response as a string.
 * /*from w w  w .  j  a  va 2s  .co m*/
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 * 
 * @param url
 *            - the resource to open: must be a welformed URL
 * @param method
 *            - the HTTP method to use ("GET", "POST", etc.)
 * @param params
 *            - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String
 * @throws MalformedURLException
 *             - if the URL format is invalid
 * @throws IOException
 *             - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }
    String response = "";
    HttpURLConnection conn = null;
    try {
        conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestProperty("User-Agent",
                System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK");
        conn.setReadTimeout(10000);
        conn.setConnectTimeout(10000);
        if (!method.equals("GET")) {
            // use method override
            params.putString("method", method);
            conn.setRequestMethod("POST");
            conn.setDoOutput(true);
            conn.getOutputStream().write(encodeUrl(params).getBytes("UTF-8"));
        }

        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    } catch (SocketTimeoutException e) {
        return response;
    }
    return response;
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

private static void logShareResult(String shareOutcome, String errorMessage) {
    Context context = FacebookSdk.getApplicationContext();
    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    Bundle parameters = new Bundle();
    parameters.putString(AnalyticsEvents.PARAMETER_SHARE_OUTCOME, shareOutcome);

    if (errorMessage != null) {
        parameters.putString(AnalyticsEvents.PARAMETER_SHARE_ERROR_MESSAGE, errorMessage);
    }//www .ja va2s. com
    logger.logSdkEvent(AnalyticsEvents.EVENT_SHARE_RESULT, null, parameters);
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param accessToken     the access token to use, or null
 * @param openGraphObject the Open Graph object to update, which must have a valid 'id'
 *                        property/*from www.  j  a  v  a  2 s. com*/
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUpdateOpenGraphObjectRequest(AccessToken accessToken, JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }

    String path = openGraphObject.optString("id");
    if (path == null) {
        throw new FacebookException("openGraphObject must have an id");
    }

    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param accessToken     the accessToken to use, or null
 * @param openGraphObject the Open Graph object to create; must not be null, and must have a
 *                        non-empty type and title
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 *///from w  w  w  .  ja  va 2  s .c om
public static GraphRequest newPostOpenGraphObjectRequest(AccessToken accessToken, JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("type"))) {
        throw new FacebookException("openGraphObject must have non-null 'type' property");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("title"))) {
        throw new FacebookException("openGraphObject must have non-null 'title' property");
    }

    String path = String.format(MY_OBJECTS_FORMAT, openGraphObject.optString("type"));
    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}

From source file:org.lukang.weibo.net.Utility.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("=");
            try {
                params.putString(URLDecoder.decode(v[0], "utf-8"), URLDecoder.decode(v[1], "utf-8"));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();/*from   w  w w  . jav a 2  s.c  o  m*/
            }
        }
    }
    return params;
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param placeId     an optional place id to associate with the post
 * @param tagIds      an optional list of user ids to tag in the post
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 *///from w  w  w.j ava 2 s.  c  o m
private static GraphRequest newStatusUpdateRequest(AccessToken accessToken, String message, String placeId,
        List<String> tagIds, Callback callback) {

    Bundle parameters = new Bundle();
    parameters.putString("message", message);

    if (placeId != null) {
        parameters.putString("place", placeId);
    }

    if (tagIds != null && tagIds.size() > 0) {
        String tags = TextUtils.join(",", tagIds);
        parameters.putString("tags", tags);
    }

    return new GraphRequest(accessToken, MY_FEED, parameters, HttpMethod.POST, callback);
}

From source file:com.facebook.internal.Utility.java

private static GraphObject getAppSettingsQueryResponse(String applicationId) {
    Bundle appSettingsParams = new Bundle();
    appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

    Request request = Request.newGraphPathRequest(null, applicationId, null);
    request.setSkipClientToken(true);/*w  ww  .jav  a 2s .  c  o  m*/
    request.setParameters(appSettingsParams);

    GraphObject response = request.executeAndWait().getGraphObject();
    return response;
}