Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:mc.inappbilling.v3.InAppBillingHelper.java

/**
 * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase, which will involve
 * bringing up the Google Play screen. The calling activity will be paused while the user interacts with Google Play, and
 * the result will be delivered via the activity's {@link android.app.Activity#onActivityResult} method, at which point
 * you must call this object's {@link #handleActivityResult} method to continue the purchase flow. This method MUST be
 * called from the UI thread of the Activity.
 * //w  w  w.j a  va 2s .c  o m
 * @param act
 *            The calling activity.
 * @param sku
 *            The sku of the item to purchase.
 * @param requestCode
 *            A request code (to differentiate from other responses -- as in
 *            {@link android.app.Activity#startActivityForResult}).
 * @param listener
 *            The listener to notify when the purchase process finishes
 * @param extraData
 *            Extra data (developer payload), which will be returned with the purchase data when the purchase completes.
 *            This extra data will be permanently bound to that purchase and will always be returned when the purchase is
 *            queried.
 */
public void launchPurchaseFlow(Activity act, String sku, int requestCode,
        OnIabPurchaseFinishedListener listener, String extraData) {
    checkSetupDone("launchPurchaseFlow");
    flagStartAsync("launchPurchaseFlow");
    InAppBillingResult result;

    try {
        logDebug("Constructing buy intent for " + sku);
        Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, ITEM_TYPE_INAPP,
                extraData);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logError("Unable to buy item, Error response: " + getResponseDesc(response));

            result = new InAppBillingResult(response, "Unable to buy item");
            if (listener != null) {
                listener.onIabPurchaseFinished(result, null);
            }
            return;
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode);
        mRequestCode = requestCode;
        mPurchaseListener = listener;
        if (pendingIntent == null) {
            logError("RESPONSE_BUY_INTENT(pendingIntent) is null!");
            return;
        }
        act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        logError("SendIntentException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new InAppBillingResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent.");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
    } catch (RemoteException e) {
        logError("RemoteException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new InAppBillingResult(IABHELPER_REMOTE_EXCEPTION,
                "Remote exception while starting purchase flow");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
    }
}

From source file:com.android.mail.ui.AnimatedAdapter.java

public void onRestoreInstanceState(Bundle outState) {
    if (outState.containsKey(LAST_DELETING_ITEMS)) {
        final long[] lastDeleting = outState.getLongArray(LAST_DELETING_ITEMS);
        for (final long aLastDeleting : lastDeleting) {
            mLastDeletingItems.add(aLastDeleting);
        }/*from  w ww.j a  va 2  s  .c  o m*/
    }
    if (outState.containsKey(LEAVE_BEHIND_ITEM_DATA)) {
        LeaveBehindData left = (LeaveBehindData) outState.getParcelable(LEAVE_BEHIND_ITEM_DATA);
        mLeaveBehindItems.put(outState.getLong(LEAVE_BEHIND_ITEM_ID),
                setupLeaveBehind(left.data, left.op, left.data.position, left.height));
    }
}

From source file:com.chen.mail.ui.FolderListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    setInstanceFromBundle(getArguments());

    final View rootView = inflater.inflate(R.layout.folder_list, null);
    mListView = (ListView) rootView.findViewById(android.R.id.list);
    mListView.setEmptyView(null);//w ww. j  av a2  s.  c  o  m
    mListView.setDivider(null);
    if (savedState != null && savedState.containsKey(BUNDLE_LIST_STATE)) {
        mListView.onRestoreInstanceState(savedState.getParcelable(BUNDLE_LIST_STATE));
    }
    if (savedState != null && savedState.containsKey(BUNDLE_SELECTED_FOLDER)) {
        mSelectedFolderUri = new FolderUri(Uri.parse(savedState.getString(BUNDLE_SELECTED_FOLDER)));
        mSelectedFolderType = savedState.getInt(BUNDLE_SELECTED_TYPE);
    } else if (mParentFolder != null) {
        mSelectedFolderUri = mParentFolder.folderUri;
        // No selected folder type required for hierarchical lists.
    }

    return rootView;
}

From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.w("onCreate", "called");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.key_card);//  w ww. j  ava  2 s.com
    typeArrows = (ImageView) findViewById(R.id.key_card_type_arrows);
    if (savedInstanceState != null) {
        photoUri = savedInstanceState.getParcelable("photoUri");
        keyCard = savedInstanceState.getParcelable("keyCard");
        isInEditMode = savedInstanceState.getBoolean(IS_IN_EDIT_MODE, false);
    }
    isInEditMode = getIntent().getBooleanExtra(IS_IN_EDIT_MODE, false);
    // this.keyCard = Service.getInstance(this).getKeyCard(keyCardId);
    this.keyCardDataSource = new KeyCardDataSource(this);
    this.valuesDataSource = new ValuesDataSource(this);
    this.fileDataSource = new FileDataSource(this);
    this.tagDataSource = new TagDataSource(this);
    bottom = (LinearLayout) findViewById(R.id.key_card_specific_items_layout);
    long keyCardId = this.getIntent().getLongExtra(KEY_CARD_ID, -1);
    if (keyCardId == -1) {
        keyCard = new KeyCard();
    } else {
        try {
            this.keyCard = keyCardDataSource.get(keyCardId);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            Toast.makeText(this, "No such keycard found in database.", Toast.LENGTH_LONG).show();
            this.finish();

        }
    }
    Log.w("Selected key card: ", keyCard.toString());
    keyCardName = (EditText) findViewById(R.id.key_card_name_edit_text);
    keyCardName.setText(keyCard.getName());
    //
    this.selectTagDialog = new TagDialog(KeyCardEditActivity.this, KeyCardEditActivity.this);
    selectedTags = (LinearLayout) findViewById(R.id.key_card_tags_selected);
    initializeTagSpinner();
    // initFavourite();
    keyCardTypeDataSource = new KeyCardTypesDataSource(this);
    keyCardTypeDataSource.open();
    if (keyCard.getKeyCardTypeId() == null) {
        keyCard.setKeyCardTypeId(1L);
    }
    KeyCardType keyCardType = keyCardTypeDataSource.getTypeById(keyCard.getKeyCardTypeId());
    // Cache.getInstance(this)
    // .getKeyCardTypeEnum(keyCard.getKeyCardTypeId()).getTitle();
    this.componentHolder = new CustomComponentHolder(this);
    initializeTypeSpinner(keyCardType);
    initializeFilesLists();

    initializeBottom();
    setDeleteButton();
    if ((keyCard.getValueIds() == null) || (keyCard.getValueIds().length < 1) || (isInEditMode)) {
        setKeyCardActionbarEdit();
    } else {
        setKeyCardActionbarView();
    }

}

From source file:me.ccrama.redditslide.util.IabHelper.java

/**
 * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,
 * which will involve bringing up the Google Play screen. The calling activity will be paused while
 * the user interacts with Google Play, and the result will be delivered via the activity's
 * {@link Activity#onActivityResult} method, at which point you must call
 * this object's {@link #handleActivityResult} method to continue the purchase flow. This method
 * MUST be called from the UI thread of the Activity.
 *
 * @param act         The calling activity.
 * @param sku         The sku of the item to purchase.
 * @param itemType    indicates if it's a product or a subscription (ITEM_TYPE_INAPP or ITEM_TYPE_SUBS)
 * @param requestCode A request code (to differentiate from other responses --
 *                    as in {@link Activity#startActivityForResult}).
 * @param listener    The listener to notify when the purchase process finishes
 * @param extraData   Extra data (developer payload), which will be returned with the purchase data
 *                    when the purchase completes. This extra data will be permanently bound to that purchase
 *                    and will always be returned when the purchase is queried.
 *//*from   ww w . j ava 2  s . co  m*/
private void launchPurchaseFlow(Activity act, String sku, String itemType, int requestCode,
        OnIabPurchaseFinishedListener listener, String extraData) {
    checkNotDisposed();
    checkSetupDone("launchPurchaseFlow");
    flagStartAsync("launchPurchaseFlow");
    IabResult result;

    if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) {
        IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, "Subscriptions are not available.");
        flagEndAsync();
        if (listener != null)
            listener.onIabPurchaseFinished(r, null);
        return;
    }

    try {
        logDebug("Constructing buy intent for " + sku + ", item type: " + itemType);
        Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logError("Unable to buy item, Error response: " + getResponseDesc(response));
            flagEndAsync();
            result = new IabResult(response, "Unable to buy item");
            if (listener != null)
                listener.onIabPurchaseFinished(result, null);
            return;
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode);
        mRequestCode = requestCode;
        mPurchaseListener = listener;
        mPurchasingItemType = itemType;
        act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        logError("SendIntentException while launching purchase flow for sku " + sku);
        e.printStackTrace();
        flagEndAsync();

        result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent.");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
    } catch (RemoteException e) {
        logError("RemoteException while launching purchase flow for sku " + sku);
        e.printStackTrace();
        flagEndAsync();

        result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
    }
}

From source file:br.com.cpb.esperanca.iab.IabHelper.java

/**
 * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,
 * which will involve bringing up the Google Play screen. The calling activity will be paused while
 * the user interacts with Google Play, and the result will be delivered via the activity's
 * {@link android.app.Activity#onActivityResult} method, at which point you must call
 * this object's {@link #handleActivityResult} method to continue the purchase flow. This method
 * MUST be called from the UI thread of the Activity.
 * //from   w  ww.ja  v a  2 s  .  com
 * @param act
 *            The calling activity.
 * @param sku
 *            The sku of the item to purchase.
 * @param requestCode
 *            A request code (to differentiate from other responses --
 *            as in {@link android.app.Activity#startActivityForResult}).
 * @param listener
 *            The listener to notify when the purchase process finishes
 * @param extraData
 *            Extra data (developer payload), which will be returned with the purchase data
 *            when the purchase completes. This extra data will be permanently bound to that purchase
 *            and will always be returned when the purchase is queried.
 */
public void launchPurchaseFlow(Activity act, String sku, int requestCode,
        OnIabPurchaseFinishedListener listener, String extraData) {
    checkSetupDone("launchPurchaseFlow");
    flagStartAsync("launchPurchaseFlow");
    IabResult result;

    try {
        //            String purchaseToken = "inapp:" + act.getPackageName() + ":android.test.purchased";
        //            mService.consumePurchase(3, act.getPackageName(), purchaseToken);

        logDebug("Constructing buy intent for " + sku);
        Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, ITEM_TYPE_INAPP,
                extraData);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logError("Unable to buy item, Error response: " + getResponseDesc(response));

            result = new IabResult(response, "Unable to buy item");
            if (listener != null) {
                listener.onIabPurchaseFinished(result, null);
            }
            return;
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode);
        mRequestCode = requestCode;
        mPurchaseListener = listener;
        act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        logError("SendIntentException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent.");
        if (listener != null) {
            listener.onIabPurchaseFinished(result, null);
        }
    } catch (RemoteException e) {
        logError("RemoteException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow");
        if (listener != null) {
            listener.onIabPurchaseFinished(result, null);
        }
    }
}

From source file:com.gmail.emerssso.srbase.EditSRActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_sr_activity);

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.edit_sr);
    }/*from w ww .ja va2s  . c om*/

    mSRNumber = (EditText) findViewById(R.id.SRNumber);
    mCustomer = (EditText) findViewById(R.id.customerName);
    mModelNumber = (EditText) findViewById(R.id.modelNumber);
    mSerialNumber = (EditText) findViewById(R.id.serialNumber);
    mDescription = (EditText) findViewById(R.id.description);
    mBusinessName = (EditText) findViewById(R.id.businessName);
    /* The Daily Button opens a dialog to add a new daily
    associated with this SR. */
    Button mDaily = (Button) findViewById(R.id.add_daily);
    /* The Part Button opens a new dialog to add a new part
    associated with this SR.. */
    Button mPart = (Button) findViewById(R.id.add_part);
    /* The Confirm Button saves the SR to the database. */
    Button mEnter = (Button) findViewById(R.id.confirm);

    Bundle extras = getIntent().getExtras();

    savedUri = (savedInstanceState == null) ? null
            : (Uri) savedInstanceState.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE);

    if (extras != null) {
        savedUri = extras.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE);
        fillData(savedUri);
    }

    if (savedUri != null) {
        myId = savedUri.getLastPathSegment();
    }

    mEnter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSRNumber.getText().toString().length() == 0) {
                Toast.makeText(EditSRActivity.this, "SR Number missing", Toast.LENGTH_LONG).show();
            } else {
                saveState();
                setResult(RESULT_OK);
                finish();
            }
        }
    });

    mPart.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveState();
            addPart();
        }
    });

    mDaily.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveState();
            addDaily();
        }
    });
}

From source file:aksha.upcomingdemo.HorizontalListView.java

@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;

        // Restore our state from the bundle
        mRestoreX = Integer.valueOf((bundle.getInt(BUNDLE_ID_CURRENT_X)));

        // Restore out parent's state from the bundle
        super.onRestoreInstanceState(bundle.getParcelable(BUNDLE_ID_PARENT_STATE));
    }/*  w  w  w  . j av a2 s.c  o m*/
}

From source file:com.redoceanred.android.billing.util.IabHelper.java

/**
 * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,
 * which will involve bringing up the Google Play screen. The calling activity will be paused while
 * the user interacts with Google Play, and the result will be delivered via the activity's
 * {@link android.app.Activity#onActivityResult} method, at which point you must call
 * this object's {@link #handleActivityResult} method to continue the purchase flow. This method
 * MUST be called from the UI thread of the Activity.
 *
 * @param act The calling activity.//  w  ww  . j  a va2 s .c  om
 * @param sku The sku of the item to purchase.
 * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or ITEM_TYPE_SUBS)
 * @param requestCode A request code (to differentiate from other responses --
 *     as in {@link android.app.Activity#startActivityForResult}).
 * @param listener The listener to notify when the purchase process finishes
 * @param extraData Extra data (developer payload), which will be returned with the purchase data
 *     when the purchase completes. This extra data will be permanently bound to that purchase
 *     and will always be returned when the purchase is queried.
 */
public void launchPurchaseFlow(Activity act, String sku, String itemType, int requestCode,
        OnIabPurchaseFinishedListener listener, String extraData) {
    checkSetupDone("launchPurchaseFlow");
    flagStartAsync("launchPurchaseFlow");
    IabResult result;

    if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) {
        IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, "Subscriptions are not available.");
        if (listener != null)
            listener.onIabPurchaseFinished(r, null);
        flagEndAsync();
        return;
    }

    try {
        logDebug("Constructing buy intent for " + sku + ", item type: " + itemType);
        Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logError("Unable to buy item, Error response: " + getResponseDesc(response));

            result = new IabResult(response, "Unable to buy item");
            if (listener != null)
                listener.onIabPurchaseFinished(result, null);
            flagEndAsync();
            return;
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode);
        mRequestCode = requestCode;
        mPurchaseListener = listener;
        mPurchasingItemType = itemType;
        act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        logError("SendIntentException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent.");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
        flagEndAsync();
    } catch (RemoteException e) {
        logError("RemoteException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow");
        if (listener != null)
            listener.onIabPurchaseFinished(result, null);
        flagEndAsync();
    }
}

From source file:com.soomla.store.billing.nokia.NokiaIabHelper.java

/**
 * See parent/*ww  w.j ava  2  s .  c  o m*/
 */
@Override
protected void launchPurchaseFlowInner(Activity act, String sku, String extraData) {
    IabResult result;

    try {
        SoomlaUtils.LogDebug(TAG, "Constructing buy intent for " + sku + ", item type: " + ITEM_TYPE_INAPP);
        Bundle buyIntentBundle = mService.getBuyIntent(3, SoomlaApp.getAppContext().getPackageName(), sku,
                ITEM_TYPE_INAPP, extraData);
        buyIntentBundle.putString("PURCHASE_SKU", sku);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != IabResult.BILLING_RESPONSE_RESULT_OK) {
            SoomlaUtils.LogError(TAG,
                    "Unable to buy item, Error response: " + IabResult.getResponseDesc(response));

            IabPurchase failPurchase = new IabPurchase(ITEM_TYPE_INAPP, "{\"productId\":" + sku + "}", "");
            result = new IabResult(response, "Unable to buy item");
            purchaseFailed(result, failPurchase);
            act.finish();
            return;
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        SoomlaUtils.LogDebug(TAG, "Launching buy intent for " + sku + ". Request code: " + RC_REQUEST);
        mPurchasingItemSku = sku;
        mPurchasingItemType = ITEM_TYPE_INAPP;

        act.startIntentSenderForResult(pendingIntent.getIntentSender(), RC_REQUEST, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } catch (SendIntentException e) {
        SoomlaUtils.LogError(TAG, "SendIntentException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IabResult.IABHELPER_SEND_INTENT_FAILED, "Failed to send intent.");
        purchaseFailed(result, null);
    } catch (RemoteException e) {
        SoomlaUtils.LogError(TAG, "RemoteException while launching purchase flow for sku " + sku);
        e.printStackTrace();

        result = new IabResult(IabResult.IABHELPER_REMOTE_EXCEPTION,
                "Remote exception while starting purchase flow");
        purchaseFailed(result, null);
    } catch (JSONException e) {
        SoomlaUtils.LogError(TAG, "Failed to generate failing purchase.");
        e.printStackTrace();

        result = new IabResult(IabResult.IABHELPER_BAD_RESPONSE, "Failed to generate failing purchase.");
        purchaseFailed(result, null);
    }

}