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.mirasense.scanditsdk.plugin.ScanditSDKActivity.java

@Override
public void didEnter(String entry) {
    if (!mContinuousMode) {
        Intent intent = new Intent();
        intent.putExtra("barcode", entry.trim());
        intent.putExtra("symbology", "UNKNOWN");
        setResult(MANUAL, intent);//from  w ww.  ja  v  a2s. c  om
        finish();
    } else {
        Bundle bundle = new Bundle();
        bundle.putString("barcode", entry.trim());
        bundle.putString("symbology", "UNKNOWN");
        ScanditSDKResultRelay.onResult(bundle);
    }
}

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

@Test
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 w w.jav a  2  s  . c  o  m*/

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
    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"), TestUtils.DOUBLE_EQUALS_DELTA);
    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:net.idlesoft.android.apps.github.activities.FileViewer.java

@Override
protected void onSaveInstanceState(final Bundle outState) {
    outState.putString("html", mHtml);
    super.onSaveInstanceState(outState);
}

From source file:org.anhonesteffort.flock.registration.model.FlockAccount.java

public Bundle toBundle() throws JsonProcessingException {
    Bundle bundle = new Bundle();

    bundle.putString(KEY_ACCOUNT_ID, id);
    bundle.putInt(KEY_VERSION, version);
    bundle.putString(KEY_STRIPE_CUSTOMER_ID, stripeCustomerId);
    bundle.putString(KEY_PASSWORD_SHA512, passwordSha512);
    bundle.putLong(KEY_CREATE_DATE, createDate.getTime());
    bundle.putBoolean(KEY_LAST_STRIPE_CHARGE_FAILED, lastStripeChargeFailed);
    bundle.putBoolean(KEY_AUTO_RENEW_ENABLED, autoRenewEnabled);
    bundle.putInt(KEY_SUBSCRIPTION_PLAN_TYPE, subscriptionPlan.getPlanType());
    bundle.putString(KEY_SUBSCRIPTION_PLAN, subscriptionPlan.serialize());

    return bundle;
}

From source file:com.ryan.ryanreader.activities.CommentEditActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString("commentText", textEdit.getText().toString());
    outState.putString("commentIdAndType", commentIdAndType);
}

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

@Override
public void onBackPressed() {
    Intent ii = new Intent(getApplicationContext(), MainMenu.class);
    Bundle b = new Bundle();
    b.putString("employeeType", "Service");
    ii.putExtras(b);//  w w  w.  ja v a2 s  .com

    startActivity(ii);
    finish();
}

From source file:club.frickel.feelathome.DeviceFragment.java

private void onEffectSelected(Effect effect) {
    Fragment effectConfigFragment = null;
    assert effect.getConfig() != null;
    switch (effect.getName()) {
    case "Wheel":
    case "Wheel2":
    case "Rainbow":
    case "Sunrise":
    case "Stroboscope":
    case "Whitefade":
    case "Random Brightness":
    case "Random Fade":
    case "Random Color":
        effectConfigFragment = new OnlyOneDelayEffectConfigFragment();
        break;/*from  w w  w . j a  v a2s  .c o m*/
    case "Color":
    case "Clock Color":
        effectConfigFragment = new OneColorEffectConfigFragment();
        break;
    case "Brightness":
    case "Brightness Scaling":
        effectConfigFragment = new BrightnessEffectConfigFragment();
        break;
    case "Colorfade":
        effectConfigFragment = new OneColorDelayEffectConfigFragment();
        break;
    case "Fire":
        effectConfigFragment = new FireEffectConfigFragment();
        break;
    case "Power": {
        effect.getConfig().put("Power", true);
        break;
    }
    }
    new SendStateHandler(effect, deviceID, getActivity()).execute();

    if (effectConfigFragment != null) {
        Bundle bundle = new Bundle();
        bundle.putString(Constants.DEVICE_ID, deviceID);
        bundle.putSerializable(Constants.EFFECT_STRING, effect);
        effectConfigFragment.setArguments(bundle);
        ((Main) getActivity()).replaceFragmentAndAddToBackstack(effectConfigFragment);
    }
}

From source file:com.adkdevelopment.e_contact.ui.presenters.ProfilePresenter.java

/**
 * Gets profile information from Facebook API
 * and calls getPhotos to retrieve photos from this profile
 *///from  w w  w  .jav a2s . c om
private void getUser() {
    // user, parse response
    GraphRequest request = GraphRequest.newMeRequest(mAccessToken, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            ProfileRealm profileRealm = new ProfileRealm();
            try {
                profileRealm.setId(object.getString(RESP_ID));
                profileRealm.setName(object.getString(RESP_NAME));
                profileRealm.setLink(object.getString(RESP_LINK));
            } catch (JSONException e) {
                Log.e(TAG, "Error: " + e);
            }

            getPhotos(profileRealm);

        }
    });

    Bundle parameters = new Bundle();
    parameters.putString(PARAM_FIELDS, TextUtils.join(",", new String[] { RESP_ID, RESP_NAME, RESP_LINK }));
    request.setParameters(parameters);

    request.executeAsync();
}

From source file:com.familygraph.android.Example.java

/** Called when the activity is first created. */
@Override//from  w  ww.  j  av a2  s.  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (CLIENT_ID == null) {
        Util.showAlert(this, "Warning", "FamilyGraph Applicaton ID must be "
                + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);
    mLoginButton = (LoginButton) findViewById(R.id.loginButton);
    mText = (TextView) Example.this.findViewById(R.id.txt);
    mPersonalPhoto = (ImageView) Example.this.findViewById(R.id.personalPhoto);
    mRequestButton = (Button) findViewById(R.id.requestButton);

    mFamilyGraph = new FamilyGraph(CLIENT_ID);
    mAsyncRunner = new AsyncFamilyGraphRunner(mFamilyGraph);

    SessionStore.restore(mFamilyGraph, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());

    String[] permissions = { "basic", "offline_access" };
    mLoginButton.init(this, mFamilyGraph, permissions);

    mRequestButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mFamilyGraph.isSessionValid()) {
                Bundle params = new Bundle();
                params.putString("fields", "name,picture");
                mAsyncRunner.request("me", params, new SampleRequestListener());
            }
        }
    });
    int visibility = mFamilyGraph.isSessionValid() ? View.VISIBLE : View.INVISIBLE;
    mRequestButton.setVisibility(visibility);
    mPersonalPhoto.setVisibility(View.INVISIBLE);
}

From source file:com.eutectoid.dosomething.usersettings.UserSettingsFragment.java

private void fetchUserInfo() {
    final AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken != null) {
        GraphRequest request = GraphRequest.newMeRequest(accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override//from  ww w  .ja va  2s  .  c  o m
                    public void onCompleted(JSONObject me, GraphResponse response) {
                        user = me;
                        updateUI();
                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString(FIELDS, REQUEST_FIELDS);
        request.setParameters(parameters);
        GraphRequest.executeBatchAsync(request);
    } else {
        user = null;
    }
}