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.ateam.alleneatonautorentals.SalesViewUsers.java

@Override
public void onBackPressed() {
    Intent ii = new Intent(SalesViewUsers.this, MainMenu.class);
    Bundle b = new Bundle();
    b.putString("employeeType", "Sales");
    ii.putExtras(b);/* w w  w  . j a v  a2  s  .c  o m*/

    startActivity(ii);
    finish();
}

From source file:com.groupme.sdk.util.HttpUtilsTest.java

public void testSetHttpParamsGet() {
    MockHttpClient client = new MockHttpClient();
    client.setContext(getContext());/*w  ww  . j  a  v a 2 s  .  co m*/
    String response = null;

    try {
        Bundle params = new Bundle();
        params.putString("group", "mygroup");
        params.putString("format", "json");

        response = HttpUtils.openUrl(client, OK_REQUEST, HttpUtils.METHOD_GET, null, params, null);
    } catch (HttpResponseException e) {
        fail("Received a response exception: " + e.toString());
    }

    String query = client.getRequest().getURI().getQuery();
    Bundle requestParams = HttpUtils.decodeParams(query);

    if (requestParams != null && !requestParams.isEmpty()) {
        assertEquals("mygroup", requestParams.getString("group"));
        assertEquals("json", requestParams.getString("format"));
    } else {
        fail("Params are not set!");
    }

    if (response == null) {
        fail("Unexpected empty response");
    }
}

From source file:com.sawyer.advadapters.app.adapters.jsonadapter.JSONAdapterFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(STATE_LIST, getListAdapter().getJSONArray().toString());
    outState.putInt(STATE_CAB_CHECKED_COUNT, mCheckedCount);
}

From source file:mobisocial.musubi.social.FacebookFriendFetcher.java

public byte[] getLoggedinUserPhoto() {
    if (mFacebook.isSessionValid()) {
        Bundle params = new Bundle();
        params.putString("access_token", mFacebook.getAccessToken());
        String url = "https://graph.facebook.com/me/picture" + "?" + Util.encodeUrl(params);
        return getImageFromURL(url);
    }/*from   ww w  . j a  v  a  2s  .co m*/

    return null;
}

From source file:com.comu.android.StreamJsHandler.java

public void postComment(final String post_id, final String message) {
    Bundle params = new Bundle();
    params.putString("message", message);

    getFb().request(post_id + "/comments", params, "POST", new AsyncRequestListener() {

        public void onComplete(JSONObject response, final Object state) {

            try {
                String html = renderComment(response, message);
                html = html.replace("'", "\\'");
                callJs("onComment('" + post_id + "','" + html + "');");
            } catch (JSONException e) {
                e.printStackTrace();/*from  w w  w . java  2s  .c o m*/
            }

        }
    }, null);
}

From source file:com.comu.android.StreamJsHandler.java

/**
 * Update the status and render the resulting status at the
 * top of the stream./* w  w  w .j  a va  2  s.c  om*/
 *  
 * @param message
 */
public void updateStatus(final String message) {
    AsyncFacebookRunner fb = getFb();
    Bundle params = new Bundle();
    params.putString("message", message);
    fb.request("me/feed", params, "POST", new AsyncRequestListener() {

        public void onComplete(JSONObject obj, final Object state) {
            String html;
            try {
                html = renderStatus(obj, message);
                html = html.replace("'", "\\\'");
                callJs("onStatusUpdated('" + html + "');");
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }, null);
}

From source file:com.ubikod.capptain.android.sdk.track.CapptainTrackReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    /* Once the application identifier is known */
    if ("com.ubikod.capptain.intent.action.APPID_GOT".equals(intent.getAction())) {
        /* Init the tracking agent */
        String appId = intent.getStringExtra("appId");
        CapptainTrackAgent.getInstance(context).onAppIdGot(appId);
    }// ww  w.  ja  v  a2s .c om

    /* During installation, an install referrer may be triggered */
    else if ("com.android.vending.INSTALL_REFERRER".equals(intent.getAction())) {
        /* Forward this action to configured receivers */
        String forwardList = CapptainUtils.getMetaData(context)
                .getString("capptain:track:installReferrerForwardList");
        if (forwardList != null)
            for (String component : forwardList.split(","))
                if (!component.equals(getClass().getName())) {
                    Intent clonedIntent = new Intent(intent);
                    clonedIntent.setComponent(new ComponentName(context, component));
                    context.sendBroadcast(clonedIntent);
                }

        /* Guess store from referrer */
        String referrer = Uri.decode(intent.getStringExtra("referrer"));
        String store;

        /* GetJar uses an opaque string always starting with z= */
        if (referrer.startsWith("z="))
            store = "GetJar";

        /* Assume Android Market otherwise */
        else
            store = "Android Market";

        /* Look for a source parameter */
        Uri uri = Uri.parse("a://a?" + referrer);
        String source = uri.getQueryParameter("utm_source");

        /*
         * Skip "androidmarket" source, this is the default one when not set or installed via web
         * Android Market.
         */
        if ("androidmarket".equals(source))
            source = null;

        /* Send app info to register store/source */
        Bundle appInfo = new Bundle();
        appInfo.putString("store", store);
        if (source != null) {
            /* Parse source, if coming from capptain, it may be a JSON complex object */
            try {
                /* Convert JSON to bundle (just flat strings) */
                JSONObject jsonInfo = new JSONObject(source);
                Iterator<?> keyIt = jsonInfo.keys();
                while (keyIt.hasNext()) {
                    String key = keyIt.next().toString();
                    appInfo.putString(key, jsonInfo.getString(key));
                }
            } catch (JSONException jsone) {
                /* Not an object, process as a string */
                appInfo.putString("source", source);
            }
        }

        /* Send app info */
        CapptainAgent.getInstance(context).sendAppInfo(appInfo);
    }
}

From source file:com.clearcenter.mobile_demo.mdAuthenticator.java

public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle loginOptions) throws NetworkErrorException {
    Log.v(TAG, "getAuthToken()");

    // If the caller requested an authToken type we don't support, then
    // return an error
    if (!authTokenType.equals(mdConstants.AUTHTOKEN_TYPE)) {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType");
        return result;
    }/*from   w w w  .j  a va2 s  . co  m*/

    // Extract the username and password from the Account Manager, and ask
    // the server for an appropriate AuthToken.
    final AccountManager am = AccountManager.get(ctx);
    final String password = am.getPassword(account);
    final String hostname = am.getUserData(account, "hostname");
    final String username = am.getUserData(account, "username");

    if (password != null) {
        try {
            mdSSLUtil.DisableSecurity();

            final String authToken = mdRest.Login(hostname, username, null, password);
            if (!TextUtils.isEmpty(authToken)) {
                final Bundle result = new Bundle();
                result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
                result.putString(AccountManager.KEY_ACCOUNT_TYPE, mdConstants.ACCOUNT_TYPE);
                result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
                return result;
            }
        } catch (JSONException e) {
            Log.e(TAG, "JSONException", e);
        } catch (GeneralSecurityException e) {
            Log.e(TAG, "GeneralSecurityException", e);
        }
    }

    Log.v(TAG, "Asking for password again...");

    // If we get here, then we couldn't access the user's password - so we
    // need to re-prompt them for their credentials. We do that by creating
    // an intent to display our mdAuthenticatorActivity panel.
    final Intent intent = new Intent(ctx, mdAuthenticatorActivity.class);
    intent.putExtra(mdAuthenticatorActivity.PARAM_NICKNAME, account.name);
    intent.putExtra(mdAuthenticatorActivity.PARAM_USERNAME, username);
    intent.putExtra(mdAuthenticatorActivity.PARAM_HOSTNAME, hostname);
    intent.putExtra(mdAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(mdAuthenticatorActivity.PARAM_CONFIRM_CREDENTIALS, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);

    return bundle;
}

From source file:com.jiramot.foursquare.android.FSAPITest.java

private String searchVenue() throws MalformedURLException, IOException {
    Bundle b = new Bundle();
    b.putString("ll", "45.40, 11.88");
    return foursquare.request("venues/search", b);
}

From source file:com.manning.androidhacks.hack023.authenticator.Authenticator.java

@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle options) throws NetworkErrorException {

    if (!authTokenType.equals(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE)) {

        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType");

        return result;
    }// ww w . ja va2 s  .  c om

    final AccountManager am = AccountManager.get(mContext);
    final String password = am.getPassword(account);

    if (password != null) {
        boolean verified = false;

        String loginResponse = null;
        try {
            loginResponse = LoginServiceImpl.sendCredentials(account.name, password);
            verified = LoginServiceImpl.hasLoggedIn(loginResponse);
        } catch (AndroidHacksException e) {
            verified = false;
        }

        if (verified) {
            final Bundle result = new Bundle();
            result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
            result.putString(AccountManager.KEY_ACCOUNT_TYPE, AuthenticatorActivity.PARAM_ACCOUNT_TYPE);

            return result;
        }
    }
    // Password is missing or incorrect
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_USER, account.name);
    intent.putExtra(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}