Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

In this page you can find the example usage for android.content Intent getParcelableExtra.

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.jawnnypoo.geotune.activity.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_GEOFENCE:
        if (resultCode == RESULT_OK && data != null) {
            GeoTune newGeoTune = data.getParcelableExtra(EXTRA_GEOTUNE);
            newGeoTune.setActive(true);/*from w  w w .  ja v a2  s .co m*/
            mGeoTuneAdapter.addGeoTune(newGeoTune);
            adapterDataChanged();
            GeoTuneModService.registerGeoTune(getApplicationContext(), newGeoTune);
            Snackbar.make(mRoot, getString(R.string.reminder_set_tune), Snackbar.LENGTH_LONG).show();
        }
        break;
    case REQUEST_AUDIO:
        if (resultCode == RESULT_OK) {
            if (data.getData() != null) {
                Timber.d("Uri was found: %s", data.getData());
                updateGeotuneUri(data.getData());
            }
        }
        break;
    case REQUEST_NOTIFICATION:
        if (resultCode == RESULT_OK) {
            Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
            updateGeotuneUri(uri);
        }
        break;
    }
}

From source file:ca.mudar.parkcatcher.service.SyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    final boolean isLocal = intent.getBooleanExtra(Const.INTENT_EXTRA_SERVICE_LOCAL, false);
    final boolean isRemote = intent.getBooleanExtra(Const.INTENT_EXTRA_SERVICE_REMOTE, false);

    final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);
    if (receiver != null) {
        receiver.send(STATUS_RUNNING, Bundle.EMPTY);
    }/*from  w  w w.j  ava2 s  .c o m*/

    try {
        // Bulk of sync work, performed by executing several fetches from
        // local and online sources.
        if (isLocal) {
            syncLocal();
            ((ParkingApp) getApplicationContext()).setHasLoadedData(true);
        }
        if (isRemote) {
            syncRemote();
            ((ParkingApp) getApplicationContext()).setHasLoadedData(true);
        }

    } catch (HandlerException e) {
        e.printStackTrace();

        if (receiver != null) {
            /**
             * Pass back error to surface listener
             */
            final Bundle bundle = new Bundle();
            bundle.putString(Intent.EXTRA_TEXT, e.toString());
            receiver.send(STATUS_ERROR, bundle);
        }
    }

    if (receiver != null) {
        receiver.send(STATUS_FINISHED, Bundle.EMPTY);
    }
}

From source file:com.asburymotors.android.disneysocal.service.UtilityService.java

/**
 * Called when the location has been updated
 *///www. j  a va 2s .c  o m
private void locationUpdated(Intent intent) {
    Log.v(TAG, ACTION_LOCATION_UPDATED);

    // Extra new location
    Location location = intent.getParcelableExtra(FusedLocationProviderApi.KEY_LOCATION_CHANGED);

    if (location != null) {
        LatLng latLngLocation = new LatLng(location.getLatitude(), location.getLongitude());

        // Store in a local preference as well
        Utils.storeLocation(this, latLngLocation);

        // Send a local broadcast so if an Activity is open it can respond
        // to the updated location
        LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
    }
}

From source file:com.google.android.gms.samples.wallet.CheckoutActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // retrieve the error code, if available
    int errorCode = -1;
    if (data != null) {
        errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, -1);
    }//from   w w w . j  a  va 2  s . c o m
    switch (requestCode) {
    case REQUEST_CODE_MASKED_WALLET:
        switch (resultCode) {
        case Activity.RESULT_OK:
            MaskedWallet maskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET);
            launchConfirmationPage(maskedWallet);
            break;
        case Activity.RESULT_CANCELED:
            break;
        default:
            handleError(errorCode);
            break;
        }
        break;
    case WalletConstants.RESULT_ERROR:
        handleError(errorCode);
        break;
    default:
        super.onActivityResult(requestCode, resultCode, data);
        break;
    }
}

From source file:com.jaspersoft.android.jaspermobile.qa.DriveSelectFileDialog.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case RESOLVE_CONNECTION_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            mGoogleApiClient.connect();// w  w  w  .  j  a v a  2s  . co  m
        }
        break;
    case REQUEST_CODE_OPENER:
        if (resultCode == Activity.RESULT_OK) {
            DriveId driveId = (DriveId) data
                    .getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
            progressDialog.setMessage("Opening selected file");
            openSelectedFile(driveId);
        } else {
            dismiss();
        }
        break;
    }
}

From source file:com.scooter1556.sms.android.activity.FullScreenPlayerActivity.java

private void updateFromParams(Intent intent) {
    if (intent != null) {
        MediaDescriptionCompat description = intent
                .getParcelableExtra(HomeActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION);

        if (description != null) {
            updateMediaDescription(description);
        }/* ww w.j av a 2 s  .co  m*/
    }
}

From source file:com.clearbon.cordova.netswipe.NetSwipePlugin.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NetswipeSDK.REQUEST_CODE) {
        /*ArrayList<String> scanAttempts = 
        data.getStringArrayListExtra(NetswipeSDK.EXTRA_SCAN_ATTEMPTS);*/
        if (resultCode == Activity.RESULT_OK) {
            NetswipeCardInformation cardInformation = data
                    .getParcelableExtra(NetswipeSDK.EXTRA_CARD_INFORMATION);

            //TODO card type
            //CreditCardType creditCardType = cardInformation.getCardType();

            JSONObject cardInfo = new JSONObject();
            try {
                cardInfo.put("cardNumber", getStringValue(cardInformation.getCardNumber(), true));
                cardInfo.put("expiryMonth", getStringValue(cardInformation.getExpiryDateMonth(), false));
                cardInfo.put("expiryYear", getStringValue(cardInformation.getExpiryDateYear(), false));
                cardInfo.put("cvv", getStringValue(cardInformation.getCvvCode(), false));
                cardInfo.put("cardHolderName", getStringValue(cardInformation.getCardHolderName(), false));
                cardInfo.put("sortCode", getStringValue(cardInformation.getSortCode(), false));
                cardInfo.put("accountNumber", getStringValue(cardInformation.getAccountNumber(), false));
                cardInfo.put("cardNumberManuallyEntered", cardInformation.isCardNumberManuallyEntered());

                //TODO custom fields
                //String zipCode = cardInformation.getCustomField("zip_code");

                callbackContext.success(cardInfo);

            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for success callback.", e);
            } finally {
                cardInformation.clear();
                cardInfo.remove("cardNumber");
                cardInfo.remove("expiryMonth");
                cardInfo.remove("expiryYear");
                cardInfo.remove("cvv");
                cardInfo.remove("cardHolderName");
                cardInfo.remove("sortCode");
                cardInfo.remove("accountNumber");
                cardInfo.remove("cardNumberManuallyEntered");
                cardInfo = null;/*from  w  ww .j ava 2 s.  c o m*/
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            try {
                int errorCode = data.getIntExtra(NetswipeSDK.EXTRA_ERROR_CODE, 0);
                String errorMessage = data.getStringExtra(NetswipeSDK.EXTRA_ERROR_MESSAGE);

                JSONObject cardInfo = new JSONObject();
                cardInfo.put("code", errorCode);
                cardInfo.put("message", errorMessage);

                callbackContext.error(cardInfo);
            } catch (JSONException e) {
                Log.e(LogTag, "Error creating return parameters for error callback.", e);
            }
        }
    }
}

From source file:com.cerema.cloud2.ui.activity.FolderPickerActivity.java

@Override
public void onClick(View v) {
    if (v == mCancelBtn) {
        finish();//from w  ww.j  av a 2s .c  o m
    } else if (v == mChooseBtn) {
        Intent i = getIntent();
        Parcelable targetFile = i.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);

        Intent data = new Intent();
        data.putExtra(EXTRA_FOLDER, getCurrentFolder());
        if (targetFile != null) {
            data.putExtra(EXTRA_FILE, targetFile);
        }
        setResult(RESULT_OK, data);
        finish();
    }
}

From source file:com.sck.maininterface.PaymentInfo.java

@SuppressWarnings("deprecation")
@Override/*  w w w.j  a  va 2  s  .  com*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_PAYMENT) {

        if (resultCode == Activity.RESULT_OK) {

            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);

            if (confirm != null) {

                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));

                    /*   Toast.makeText(
                             getApplicationContext(),
                             "Payment Confirmation info received from PayPal",
                             Toast.LENGTH_LONG).show();*/

                    AlertDialog ad = new AlertDialog.Builder(this).create();
                    ad.setCancelable(false); // This blocks the 'BACK' button  
                    ad.setMessage("Payment Confirmation info received from PayPal");
                    ad.setButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    ad.show();
                    //new updateExpiryDate().execute();
                    //paymentSuccess=true;
                    saveExpDate(renewedDate);

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        }

        else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        }

        else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    }

    // /

}

From source file:com.android.launcher4.InstallShortcutReceiver.java

public void onReceive(Context context, Intent data) {
    if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
        return;/*from  w w w.j  a v a2  s.  c om*/
    }

    if (DBG)
        Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0));

    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (intent == null) {
        return;
    }

    // This name is only used for comparisons and notifications, so fall back to activity name
    // if not supplied
    String name = ensureValidName(context, intent, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)).toString();
    Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
    Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);

    // Queue the item up for adding if launcher has not loaded properly yet
    LauncherAppState.setApplicationContext(context.getApplicationContext());
    LauncherAppState app = LauncherAppState.getInstance();
    boolean launcherNotLoaded = (app.getDynamicGrid() == null);

    PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent);
    info.icon = icon;
    info.iconResource = iconResource;

    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    addToInstallQueue(sp, info);
    if (!mUseInstallQueue && !launcherNotLoaded) {
        flushInstallQueue(context);
    }
}