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.facebook.internal.ServerProtocol.java

public static Bundle getQueryParamsForPlatformActivityIntentWebFallback(Context context, String callId,
        int version, String applicationName, Bundle methodArgs) {

    String keyHash = Settings.getApplicationSignature(context);
    if (Utility.isNullOrEmpty(keyHash)) {
        return null;
    }/*from  w w  w. j  av  a 2  s.  co m*/

    Bundle webParams = new Bundle();

    webParams.putString(FALLBACK_DIALOG_PARAM_KEY_HASH, keyHash);
    webParams.putString(FALLBACK_DIALOG_PARAM_APP_ID, Settings.getApplicationId());
    webParams.putInt(FALLBACK_DIALOG_PARAM_VERSION, version);
    webParams.putString(DIALOG_PARAM_DISPLAY, FALLBACK_DIALOG_DISPLAY_VALUE_TOUCH);

    Bundle bridgeArguments = new Bundle();
    bridgeArguments.putString(NativeProtocol.BRIDGE_ARG_ACTION_ID_STRING, callId);
    bridgeArguments.putString(NativeProtocol.BRIDGE_ARG_APP_NAME_STRING, applicationName);

    methodArgs = (methodArgs == null) ? new Bundle() : methodArgs;

    try {
        JSONObject bridgeArgsJSON = BundleJSONConverter.convertToJSON(bridgeArguments);
        JSONObject methodArgsJSON = BundleJSONConverter.convertToJSON(methodArgs);

        if (bridgeArgsJSON == null || methodArgsJSON == null) {
            return null;
        }

        webParams.putString(FALLBACK_DIALOG_PARAM_BRIDGE_ARGS, bridgeArgsJSON.toString());
        webParams.putString(FALLBACK_DIALOG_PARAM_METHOD_ARGS, methodArgsJSON.toString());
    } catch (JSONException je) {
        webParams = null;
        Logger.log(LoggingBehavior.DEVELOPER_ERRORS, Log.ERROR, TAG, "Error creating Url -- " + je);
    }

    return webParams;
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public static Bundle queryToBundle(List<SearchQuery> query) {
    if (query == null) {
        return null;
    }//  w w  w .  j  a  va2  s .c o m
    Bundle b = new Bundle();
    for (SearchQuery q : query) {
        try {
            b.putString(q.getSearchField().toJSON().toString(), q.getValue());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return b;
}

From source file:com.facebook.notifications.sample.MainActivity.java

/**
 * Mock an example push notification bundle from one of our local example JSON files.
 * @param exampleId The example id of the asset to load
 * @return a bundle with the contents of the specified example id
 *///  www  .j  av a2s.  co m
@NonNull
private Bundle getBundle(int exampleId) {
    try {
        InputStream inputStream = getAssets().open("example" + exampleId + ".json");

        StringWriter output = new StringWriter();
        IOUtils.copy(inputStream, output, Charset.forName("UTF-8"));

        JSONObject json = new JSONObject(output.toString());

        Bundle bundle = new Bundle();
        bundle.putString("fb_push_card", json.getJSONObject("fb_push_card").toString());
        JSONObject pushPayload = json.optJSONObject("fb_push_payload");
        if (pushPayload != null) {
            bundle.putString("fb_push_payload", pushPayload.toString());
        }

        output.close();
        inputStream.close();

        return bundle;
    } catch (Exception ex) {
        Log.e(LOG_TAG, "Error while getting bundle", ex);
        return new Bundle();
    }
}

From source file:com.iStudy.Study.Renren.Util.java

/**
 * ?URL??key-value//  ww  w.  jav a  2  s  . c  om
 * 
 * @param url
 * @return
 */
public static Bundle parseUrl(String url) {
    url = url.replace("rrconnect", "http");
    url = url.replace("#", "?");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}

From source file:com.brodev.socialapp.view.MarketPlaceDetail.java

/** Called when the activity is first created. */
@Override//from w  w w .ja  v  a  2 s . c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.market_place_content_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    marketPlace = (MarketPlace) bundle.get("marketplace");

    phraseManager = new PhraseManager(getApplicationContext());
    user = (User) getApplicationContext();
    colorView = new ColorView(getApplicationContext());
    this.imageGetter = new ImageGetter(getApplicationContext());

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    if (marketPlace.getTime_stamp().equals("0")) {
        this.getMarketPlaceAdapter();
    }

    getSupportActionBar().setTitle(phraseManager.getPhrase(getApplicationContext(), "marketplace.marketplace"));
    initView();

    // get comment fragment
    Bundle comment = new Bundle();
    comment.putString("type", "marketplace");
    comment.putInt("itemId", marketPlace.getListing_id());
    comment.putInt("totalComment", marketPlace.getTotal_comment());
    comment.putInt("total_like", marketPlace.getTotal_like());
    comment.putBoolean("no_share", false);
    comment.putBoolean("is_liked", marketPlace.getIs_liked());
    comment.putBoolean("can_post_comment", marketPlace.getCan_post_comment());

    CommentFragment commentFragment = new CommentFragment();
    commentFragment.setArguments(comment);
    getSupportFragmentManager().beginTransaction().add(R.id.commentfragment_wrap, commentFragment).commit();
}

From source file:com.mobli.android.Util.java

/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 * //from  www  .  jav a 2s.  c om
 * @param url
 *            the URL to parse
 * @return a dictionary bundle of keys and values
 */
public static Bundle parseUrl(String url) {

    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}

From source file:com.cttapp.bby.mytlc.layer8apps.CalendarHandler.java

/************
 *  PURPOSE: Used to send our errors back to the main thread
 *  ARGUMENTS: String error//from   w w  w.j a va 2s  .co  m
 *  RETURNS: VOID
 *  AUTHOR: Devin Collins <agent14709@gmail.com>
 *************/
private void showError(String error) {
    Message msg = Message.obtain();
    Bundle data = new Bundle();
    data.putString("status", "ERROR");
    data.putString("error", error);
    msg.setData(data);
    try {
        messenger.send(msg);
    } catch (Exception e) {
        // TODO: Error reporting?
    }
}

From source file:com.example.firstapp.AbstractGetNameTask.java

/**
 * Contacts the user info server to get the profile of the user and extracts
 * the first name of the user from the profile. In order to authenticate
 * with the user info server the method first fetches an access token from
 * Google Play services.//from   w  ww  .j  a  v  a  2  s  .  c  om
 * @return 
 * @return 
 * 
 * @throws IOException
 *             if communication with user info server failed.
 * @throws JSONException
 *             if the response from the server could not be parsed.
 */
private void fetchNameFromProfileServer() throws IOException, JSONException {
    String token = fetchToken();
    URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    int sc = con.getResponseCode();
    if (sc == 200) {
        InputStream is = con.getInputStream();
        GOOGLE_USER_DATA = readResponse(is);
        is.close();

        Intent intent = new Intent(mActivity, HomeActivity.class);
        Bundle b = new Bundle();
        b.putSerializable("object", ob);
        intent.putExtras(b);
        intent.putExtra("email_id", mEmail);
        mActivity.startActivity(intent);
        mActivity.finish();
        return;
    } else if (sc == 401) {
        GoogleAuthUtil.invalidateToken(mActivity, token);
        onError("Server auth error, please try again.", null);
        //Toast.makeText(mActivity, "Please try again", Toast.LENGTH_SHORT).show();
        //mActivity.finish();
        return;
    } else {
        onError("Server returned the following error code: " + sc, null);
        return;
    }
}

From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java

/**
 * {@inheritDoc}/*from w w w .j av a2s . c o m*/
 */
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
    if (options != null && options.containsKey(AccountManager.KEY_PASSWORD)) {
        final String password = options.getString(AccountManager.KEY_PASSWORD);
        final Bundle verified = onlineConfirmPassword(account, password);
        final Bundle result = new Bundle();
        result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, verified != null);
        return result;
    }
    // Launch AuthenticatorActivity to confirm credentials
    final Intent intent = getAuthenticator(mContext);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name);
    intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_CONFIRMCREDENTIALS, 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.mobli.android.AsyncMobliRunner.java

public void request(String relativePath, RequestListener listener) {
    request(relativePath, new Bundle(), "GET", listener, /* state */null);
}