Example usage for android.os Bundle Bundle

List of usage examples for android.os Bundle Bundle

Introduction

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

Prototype

public Bundle() 

Source Link

Document

Constructs a new, empty Bundle.

Usage

From source file:com.tigerpenguin.places.model.Geometry.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeParcelable(location, flags);
    // Android documentation recommends using writeBundle() instead of writeMap()
    Bundle bundle = null;//  ww w . j  ava2 s.com
    if (viewports != null && viewports.size() > 0) {
        bundle = new Bundle();
        for (Map.Entry<String, PlaceLocation> viewport : viewports.entrySet()) {
            bundle.putParcelable(viewport.getKey(), viewport.getValue());
        }
    }
    dest.writeBundle(bundle);
}

From source file:com.google.firebase.quickstart.analytics.webview.AnalyticsWebInterface.java

private Bundle bundleFromJson(String json) {
    // [START_EXCLUDE]
    if (TextUtils.isEmpty(json)) {
        return new Bundle();
    }/*  ww  w  .j av  a2  s.c o  m*/

    Bundle result = new Bundle();
    try {
        JSONObject jsonObject = new JSONObject(json);
        Iterator<String> keys = jsonObject.keys();

        while (keys.hasNext()) {
            String key = keys.next();
            Object value = jsonObject.get(key);

            if (value instanceof String) {
                result.putString(key, (String) value);
            } else if (value instanceof Integer) {
                result.putInt(key, (Integer) value);
            } else if (value instanceof Double) {
                result.putDouble(key, (Double) value);
            } else {
                Log.w(TAG, "Value for key " + key + " not one of [String, Integer, Double]");
            }
        }
    } catch (JSONException e) {
        Log.w(TAG, "Failed to parse JSON, returning empty Bundle.", e);
        return new Bundle();
    }

    return result;
    // [END_EXCLUDE]
}

From source file:com.miz.mizuu.fragments.RelatedMoviesFragment.java

public static RelatedMoviesFragment newInstance(String tmdbId, boolean setBackground) {
    RelatedMoviesFragment pageFragment = new RelatedMoviesFragment();
    Bundle bundle = new Bundle();
    bundle.putString("tmdbId", tmdbId);
    bundle.putBoolean("setBackground", setBackground);
    pageFragment.setArguments(bundle);/*  w w w .  j av a 2 s  .  c  om*/
    return pageFragment;
}

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

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

    bundle.putString(KEY_ACCOUNT_ID, accountId);
    bundle.putString(KEY_LAST_FOUR, cardLastFour);
    bundle.putString(KEY_EXPIRATION, cardExpiration);

    return bundle;
}

From source file:com.google.cast.samples.games.gamedebugger.PlayerTransitionDialogFragment.java

public static PlayerTransitionDialogFragment newInstance(String playerId, boolean isTransition) {
    PlayerTransitionDialogFragment instance = new PlayerTransitionDialogFragment();
    Bundle bundle = new Bundle();
    bundle.putString(KEY_PLAYER_ID, playerId);
    bundle.putBoolean(KEY_IS_TRANSITION, isTransition);
    instance.setArguments(bundle);// w  w  w  .j  ava2s. c om
    return instance;
}

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

public void testBundleToList() {
    Bundle params = new Bundle();
    params.putString("group", "myawesomegroup");
    params.putString("platform", "android");
    params.putString("locale", "us");

    List<NameValuePair> pairs = HttpUtils.bundleToList(params);
    assertNotNull(pairs);//from   ww w . j ava  2  s . co  m
    assertEquals(pairs.size(), params.size());

    for (NameValuePair pair : pairs) {
        assertNotNull(pair);
        assertEquals(pair.getValue(), params.getString(pair.getName()));
    }
}

From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticator.java

@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) throws NetworkErrorException {

    Log.d(TAG, "Add Account");
    final Intent intent = new Intent(mContext, GMSAuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

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

public JSONArray getFriendInfo() throws Exception {
    try {/*  w  w w.j ava2s. co m*/
        // Ask for friend information as FQL
        // This query gets the user id, full name, and small profile picture
        // of all of the logged-in user's friends (and the user himself)
        if (mFacebook.isSessionValid()) {
            Bundle params = new Bundle();
            params.putString("q", "SELECT uid, name, pic_square FROM user "
                    + "WHERE uid = me() OR uid in (SELECT uid2 FROM friend WHERE uid1 = me())");
            JSONObject data = Util.parseJson(mFacebook.request("fql", params));
            if (DBG)
                Log.d(TAG, data.toString());
            return data.getJSONArray("data");
        }
    } catch (FacebookError e) {
        Log.e(TAG, "Facebook request error", e);
    }
    return null;
}

From source file:com.captix.scan.social.facebook.Util.java

@SuppressWarnings("deprecation")
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("=");
            params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1]));
        }// w w  w. j  av  a2 s .co m
    }
    return params;
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);//from  w  w  w.  j av  a 2 s .  c  o  m
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}