Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

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

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.soomla.billing.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        StoreUtils.LogDebug(TAG, "Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/*from  ww  w .ja v a2 s  .c o m*/
        StoreUtils.LogError(TAG, "Unexpected type for bundle response code.");
        StoreUtils.LogError(TAG, o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.wareninja.android.opensource.mongolab_sdk.common.WebService.java

public String getJsonFromParams(Bundle params) {// this has some fup on
    // TagLoco action, couldnt
    // find what!!!

    Map<String, Object> paramsMap = new LinkedHashMap<String, Object>();

    String valStr;/*  w  w  w.j  a v a2 s .co m*/
    Object valObj;
    for (String key : params.keySet()) {

        valObj = params.get(key);
        if (valObj instanceof String) {

            // ugly check if the string value is JSONObj or JSONArr
            valStr = "" + valObj;
            valObj = null;
            try {
                valObj = new JSONObject(valStr);
            } catch (JSONException ex) {
                valObj = null;
            }

            if (valObj == null) {
                try {
                    valObj = new JSONArray(valStr);
                } catch (JSONException ex) {
                    valObj = null;
                }
            }
            if (valObj == null)
                valObj = valStr;
        }

        if (valObj != null)
            paramsMap.put(key, valObj);
    }

    return getJsonFromParams(paramsMap);
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

void startBuyFlow() {
    if (IAPService == null) {
        // TODO: res
        Toast.makeText(this, "Impossible de faire des achats sur un appareil non support par Google.",
                Toast.LENGTH_LONG).show();
        return;//from  w  w w  . j  a  va 2s.co  m
    }

    try {
        Bundle buyIntentBundle = IAPService.getBuyIntent(3, getPackageName(), utils.SKU_DONATE, "inapp", null);
        int responseCode = (int) buyIntentBundle.get("RESPONSE_CODE");
        switch (responseCode) {
        case 0: // BILLING_RESPONSE_RESULT_OK
            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
            try {
                if (pendingIntent != null) {
                    IntentSender sender = pendingIntent.getIntentSender();
                    startIntentSenderForResult(sender, PURCHASE_REQUEST_CODE, new Intent(), 0, 0, 0);
                }
            } catch (IntentSender.SendIntentException e) {
                Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
            }
            break;
        case 1: // BILLING_RESPONSE_RESULT_USER_CANCELED
            break;
        case 3: // BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 4: // BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 5: // BILLING_RESPONSE_RESULT_DEVELOPER_ERROR
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 6: // BILLING_RESPONSE_RESULT_ERROR
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 7: // BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED
            PrefUtils.setUserDonated(this, true);
            Toast.makeText(mContext, R.string.toast_purchase_thanks, Toast.LENGTH_LONG).show();
            mAdView.destroy();
            LinearLayout adLayout = (LinearLayout) findViewById(R.id.adLayout);
            adLayout.setVisibility(View.GONE);
            break;
        case 8: // BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED
            break;
        }
    } catch (RemoteException e) {
        Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.trk.aboutme.facebook.Request.java

private static void serializeParameters(Bundle bundle, Serializer serializer) throws IOException {
    Set<String> keys = bundle.keySet();

    for (String key : keys) {
        Object value = bundle.get(key);
        if (isSupportedParameterType(value)) {
            serializer.writeObject(key, value);
        }//from   ww w .  ja v  a  2s .c om
    }
}

From source file:com.trk.aboutme.facebook.Request.java

private static void serializeAttachments(Bundle bundle, Serializer serializer) throws IOException {
    Set<String> keys = bundle.keySet();

    for (String key : keys) {
        Object value = bundle.get(key);
        if (isSupportedAttachmentType(value)) {
            serializer.writeObject(key, value);
        }//from w w  w  . ja v a2s.  c  o  m
    }
}

From source file:mp.paschalis.RequestActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_request);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    app = (App) getApplication();/*from w w  w  . j  a  v a 2  s. c o m*/

    // Get arguments, to determine who opened this activity
    final Bundle extras = getIntent().getExtras();

    try {
        dataClassActivities = (MainActivity.DataClassActivities) extras
                .get(App.ExtrasForRequestBookActivityFromActivitiesActivity);
    } catch (Exception e) {
        Toast.makeText(RequestActivity.this, R.string.msgErrorApplicationReport, Toast.LENGTH_LONG).show();
        finish();
    }

    // Get layout's Data
    TextView username = (TextView) findViewById(R.id.textViewActivityItemUsername);

    TextView date = (TextView) findViewById(R.id.textViewActivityItemDate);

    TextView acknowledgeTitle = (TextView) findViewById(R.id.textViewActivityItemAnswerTitle);
    TextView acknowledge = (TextView) findViewById(R.id.textViewActivityItemAnswer);
    TextView isbn = (TextView) findViewById(R.id.textViewActivityItemISBN);
    TextView title = (TextView) findViewById(R.id.textViewActivityItemTitle);
    TextView authors = (TextView) findViewById(R.id.textViewActivityItemAuthors);

    ImageView cover = (ImageView) findViewById(R.id.imageViewActivityBookCover);

    username.setText(dataClassActivities.username);

    date.setText(App.makeTimeStampHumanReadble(getApplicationContext(), dataClassActivities.book.dateOfInsert));

    // Set Ack Status strings
    ExpandableAdapterActivityInfo.setStatusString(dataClassActivities.acknowledge, acknowledge,
            acknowledgeTitle);

    TextView tvnc = (TextView) findViewById(R.id.textViewNoCover);
    isbn.setText(dataClassActivities.book.isbn);
    title.setText(dataClassActivities.book.title);
    authors.setText(dataClassActivities.book.authors);

    // show The Image and save it to Library
    ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover();
    bk.iv = cover;
    bk.isCover = true;
    bk.tv = tvnc;
    bk.pb = (ProgressBar) findViewById(R.id.progressBarLoadCover);
    bk.book = dataClassActivities.book;

    App.imageLoader.DisplayCover(bk);

    buttonHybrid = (Button) findViewById(R.id.buttonRequestHybrid);
    buttonContact = (Button) findViewById(R.id.buttonRequestContact);

    buttonContact.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(RequestActivity.this, SendMessageActivity.class);

            intent.putExtra(App.ExtrasForSendMessage_DestinationUser, dataClassActivities.username);

            startActivity(intent);

        }
    });

    progressBarHybrid = (ProgressBar) findViewById(R.id.progressBarRequestHybridButton);

    switch (dataClassActivities.type) {
    case IncomingRequest:
        // Other user wants my books

        if (dataClassActivities.acknowledge == App.REQUESTS_ANSWER_DINT_ANSWER_YET) {
            hButtonReplyRequest();
            buttonHybrid.setText(R.string.reply);
        } else if (dataClassActivities.acknowledge == App.REQUESTS_ANSWER_POSITIVE) {
            hButtonLentABook();
        } else {
            hButtonDeleteRequest();
        }

        break;
    case OutgoingRequest:
        // I want a book that belongs to other user

        if (dataClassActivities.acknowledge == App.REQUESTS_ANSWER_DINT_ANSWER_YET) {
            hButtonDeleteRequest();

        } else if (dataClassActivities.acknowledge == App.REQUESTS_ANSWER_POSITIVE) {
            hButtonHide();
        } else {
            hButtonDeleteRequest();
        }

        buttonHybrid.setText(R.string.deleteRequest);
        break;
    case BooksITook:
        // Book i lented from another user(took)
        hButtonHide();

        break;
    case BooksIGave:
        // Book i lent to other user(gave)
        hButtonReturnBook();
        break;

    default:
        break;
    }

}

From source file:com.novachevskyi.expenseslite.presentation.utils.purchases.utils.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer) {
        return ((Integer) o).intValue();
    } else if (o instanceof Long) {
        return (int) ((Long) o).longValue();
    } else {/*w ww  .jav  a  2  s  .co  m*/
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:acceptable_risk.nik.uniobuda.hu.andrawid.util.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/*from   ww  w.jav  a2  s . co m*/
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.yourkey.billing.util.InAppBilling.java

private int getResponseCodeFromBundle(Bundle bundle) {
    Object responseCode = bundle.get(RESPONSE_CODE);
    if (responseCode == null)
        return (RESULT_OK);
    if (responseCode instanceof Integer)
        return (((Integer) responseCode).intValue());
    if (responseCode instanceof Long)
        return ((int) ((Long) responseCode).longValue());
    return (RESULT_INVALID_RESPONSE);
}

From source file:com.onebus.view.MainActivity.java

public void onEvent(int eventType, Bundle params) {
    switch (eventType) {
    case EVENT_ERROR:
        String reason = params.get("reason") + "";
        Toast.makeText(getApplicationContext(), "EVENT_ERROR, " + reason, Toast.LENGTH_SHORT).show();
        break;// www .  ja v  a2  s  . co  m
    case VoiceRecognitionService.EVENT_ENGINE_SWITCH:
        int type = params.getInt("engine_type");
        Toast.makeText(getApplicationContext(), "*?" + (type == 0 ? "" : ""),
                Toast.LENGTH_SHORT).show();
        break;
    }
}