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.arthackday.killerapp.GCMIntentService.java

@Override
protected void onMessage(Context ctxt, Intent message) {
    Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh GCMessage");
    Bundle extras = message.getExtras();

    /*/*from  w ww  .ja va  2s.co  m*/
     * TO DO! CHANGE WHAT THE MESSAGES DO!!
     */

    for (String key : extras.keySet()) {
        Log.i(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key)));

        if (key.equals(KillerConstants.EXTRA_KEY_AUDIO)) {
            Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh pushAudio");
            Intent i = new Intent();
            Log.i("REMOVE BEFORE COMMIT", extras.getString(key));

            Bundle bundle = new Bundle();
            //Add your data to bundle
            bundle.putString(KillerConstants.EXTRA_KEY_AUDIO, extras.getString(key));
            //Add the bundle to the intent
            i.putExtras(bundle);
            i.setClassName("com.arthackday.killerapp", "com.arthackday.killerapp.PushAudio");
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
        }

        if (key.equals(KillerConstants.EXTRA_KEY_PUSHCALL)) {
            Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh callnumber");
            String number = extras.getString(KillerConstants.EXTRA_KEY_PUSHCALL);
            String uri = "tel:" + number.trim();
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse(uri));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    }
}

From source file:com.ateam.alleneatonautorentals.SalesSearchUser.java

@Override
public void onBackPressed() {
    Intent ii = new Intent(SalesSearchUser.this, MainMenu.class);
    Bundle b = new Bundle();
    b.putString("employeeType", "Sales");
    ii.putExtras(b);//ww  w. j  ava 2 s  .  c o m

    startActivity(ii);
    finish();
}

From source file:at.bitfire.davdroid.mirakel.syncadapter.LoginURLFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.next:
        FragmentTransaction ft = getFragmentManager().beginTransaction();

        Bundle args = new Bundle();
        String host_path = editBaseURI.getText().toString();
        args.putString(QueryServerDialogFragment.EXTRA_BASE_URI, URLUtils.sanitize(scheme + host_path));
        args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
        args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
        args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());

        DialogFragment dialog = new QueryServerDialogFragment();
        dialog.setArguments(args);/*from ww w.  j a v a  2 s .  c o  m*/
        dialog.show(ft, QueryServerDialogFragment.class.getName());
        break;
    default:
        return false;
    }
    return true;
}

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

@SmallTest
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);//from w ww. java  2  s .c om

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"));
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"));
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

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

/**
 * Like or unlike a post//ww w . j  av a2  s . c  om
 * 
 * @param post_id
 * @param val if the action should be a like (true) or an unlike (false)
 */
public void like(final String post_id, final boolean val) {
    Bundle params = new Bundle();
    if (!val) {
        params.putString("method", "delete");
    }
    getFb().request(post_id + "/likes", new Bundle(), "POST", new AsyncRequestListener() {

        public void onComplete(JSONObject response, final Object state) {
            callJs("javascript:onLike('" + post_id + "'," + val + ")");
        }
    }, null);
}

From source file:pt.up.mobile.authenticator.Authenticator.java

@Override
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(Constants.AUTHTOKEN_TYPE)) {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType");
        return result;
    }//from   ww  w  .  j  a va 2 s.  c o m
    try {
        final AccountManager am = AccountManager.get(mContext);
        final String peek = am.peekAuthToken(account, authTokenType);
        if (peek != null) {
            final Bundle result = new Bundle();
            result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
            result.putString(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
            result.putString(AccountManager.KEY_AUTHTOKEN, peek);
            return result;
        }
        // Extract the username and password from the Account Manager, and
        // ask
        // the server for an appropriate AuthToken.
        final String password = am.getPassword(account);
        if (password != null) {
            String[] reply;

            reply = SifeupAPI.authenticate(account.name, password, mContext);
            final String authToken = reply[1];
            if (!TextUtils.isEmpty(authToken)) {
                final Bundle result = new Bundle();
                result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
                result.putString(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
                result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
                return result;
            }
        }

    } catch (AuthenticationException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
        throw new NetworkErrorException();
    }
    // 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 AuthenticatorActivity panel.
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_CONFIRM_CREDENTIALS, true);
    intent.putExtra(AuthenticatorActivity.PARAM_USERNAME, 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;
}

From source file:com.hua.goddess.activites.RegisterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_register);
    pd = new ProgressDialog(RegisterActivity.this);
    // DeviceUuidFactory uuid = new DeviceUuidFactory(this);
    // uid = uuid.getDeviceUuid().toString();

    emailEditText = (EditText) findViewById(R.id.email);
    emailEditText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);// ??
    userNameEditText = (EditText) findViewById(R.id.username);
    passwordEditText = (EditText) findViewById(R.id.password);
    confirmPwdEditText = (EditText) findViewById(R.id.confirm_password);

    rg = (RadioGroup) findViewById(R.id.sex);
    b1 = (RadioButton) findViewById(R.id.male);
    b2 = (RadioButton) findViewById(R.id.female);
    wh = new WsRequestHelper(new WsRequestHelper.InterfaceCallBack() {
        @Override//from  w w  w .ja  va  2 s  .  c o  m
        public void RequestCallBack(Object result) {
            // TODO Auto-generated method stub
            pd.dismiss();
            // Toast.makeText(RegisterActivity.this, result.toString(),
            // Toast.LENGTH_SHORT).show();
            if (result.toString().equals("?")) {
                Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("username", userNameEditText.getText().toString().trim());

                intent.putExtras(bundle);
                setResult(100, intent);
                finish();
            }

        }
    });

    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // TODO Auto-generated method stub
            if (checkedId == b1.getId()) {
                sex = "1";
                Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show();
            }
            if (checkedId == b2.getId()) {
                sex = "2";
                Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show();
            }

        }

    });
}

From source file:com.QuarkLabs.BTCeClient.fragments.HistoryFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString("startDate", mDateFormat.format(mStartDateValue));
    outState.putString("endDate", mDateFormat.format(mEndDateValue));
}

From source file:ibp.plugin.nsd.NSDPlugin.java

private void sendByHandler(String type, String data) {
    if (null != mHandler) {
        Bundle messageBundle = new Bundle();
        messageBundle.putString("type", type);
        messageBundle.putString("msg", data);
        Message message = new Message();
        message.setData(messageBundle);//from   www .j a v a  2s .  c om
        mHandler.sendMessage(message);
    }
}

From source file:most.voip.example.remote_config.LoginActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == REMOTE_ACCOUNT_CONFIG_REQUEST) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            Intent resultIntent = new Intent();
            Bundle b = new Bundle();
            b.putString("account_data", data.getExtras().getString("account_data"));
            b.putString("buddies_data", data.getExtras().getString("buddies_data"));

            resultIntent.putExtras(b);//from ww  w .  j a va2s .  c  o m
            // TODO Add extras or a data URI to this intent as appropriate.
            Log.d("VoipConfigDemo", "Configuration accepted");
            setResult(Activity.RESULT_OK, resultIntent);

            finish();
        } else {
            Log.d("VoipConfigDemo", "Account data NOT received from the activity");
        }
    } else {
        Log.d("VoipConfigDemo", "Received unknown requestCode:" + String.valueOf(requestCode));
    }
}