List of usage examples for android.app Activity RESULT_CANCELED
int RESULT_CANCELED
To view the source code for android.app Activity RESULT_CANCELED.
Click Source Link
From source file:com.cannabiscoin.wallet.ui.SendCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.send_coins_fragment, container); payeeNameView = (TextView) view.findViewById(R.id.send_coins_payee_name); payeeOrganizationView = (TextView) view.findViewById(R.id.send_coins_payee_organization); payeeVerifiedByView = (TextView) view.findViewById(R.id.send_coins_payee_verified_by); receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address); receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null)); receivingAddressView.setOnFocusChangeListener(receivingAddressListener); receivingAddressView.addTextChangedListener(receivingAddressListener); receivingStaticView = view.findViewById(R.id.send_coins_receiving_static); receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address); receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label); receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() { private ActionMode actionMode; @Override/*from ww w . j av a 2s . com*/ public void onFocusChange(final View v, final boolean hasFocus) { if (hasFocus) { final Address address = paymentIntent.hasAddress() ? paymentIntent.getAddress() : (validatedAddress != null ? validatedAddress.address : null); if (address != null) actionMode = activity.startActionMode(new ReceivingAddressActionMode(address)); } else { actionMode.finish(); } } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc); btcAmountView.setCurrencySymbol(config.getBtcPrefix()); btcAmountView.setInputPrecision(config.getBtcMaxPrecision()); btcAmountView.setHintPrecision(config.getBtcPrecision()); btcAmountView.setShift(config.getBtcShift()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.send_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection()); directPaymentEnableView = (CheckBox) view.findViewById(R.id.send_coins_direct_payment_enable); directPaymentEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (paymentIntent.isBluetoothPaymentUrl() && isChecked && !bluetoothAdapter.isEnabled()) { // ask for permission to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } }); directPaymentMessageView = (TextView) view.findViewById(R.id.send_coins_direct_payment_message); sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction); sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(), false); sentTransactionView.setAdapter(sentTransactionListAdapter); viewGo = (Button) view.findViewById(R.id.send_coins_go); viewGo.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { validateReceivingAddress(true); isAmountValid(); if (everythingValid()) handleGo(); else requestFocusFirst(); } }); amountCalculatorLink.setNextFocusId(viewGo.getId()); viewCancel = (Button) view.findViewById(R.id.send_coins_cancel); viewCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (state == State.INPUT) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); } }); popupMessageView = (TextView) inflater.inflate(R.layout.send_coins_popup_message, container); if (savedInstanceState != null) { restoreInstanceState(savedInstanceState); } else { final Intent intent = activity.getIntent(); final String action = intent.getAction(); final Uri intentUri = intent.getData(); final String scheme = intentUri != null ? intentUri.getScheme() : null; final String mimeType = intent.getType(); if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && intentUri != null && CoinDefinition.coinURIScheme.equals(scheme)) { initStateFromBitcoinUri(intentUri); } else if ((NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final NdefMessage ndefMessage = (NdefMessage) intent .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; final byte[] ndefMessagePayload = Nfc.extractMimePayload(PaymentProtocol.MIMETYPE_PAYMENTREQUEST, ndefMessage); initStateFromPaymentRequest(mimeType, ndefMessagePayload); } else if ((Intent.ACTION_VIEW.equals(action)) && PaymentProtocol.MIMETYPE_PAYMENTREQUEST.equals(mimeType)) { final byte[] paymentRequest = BitcoinIntegration.paymentRequestFromIntent(intent); if (intentUri != null) initStateFromIntentUri(mimeType, intentUri); else if (paymentRequest != null) initStateFromPaymentRequest(mimeType, paymentRequest); else throw new IllegalArgumentException(); } else if (intent.hasExtra(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT)) { initStateFromIntentExtras(intent.getExtras()); } else { updateStateFrom(PaymentIntent.blank()); } } return view; }
From source file:com.cmput301w17t07.moody.EditMoodActivity.java
/** * Method handles user interface response to when a user adds an image to their mood * from either their camera or their gallery. * * Knowledge and logic of onActivityResult referenced and taken from <br> * link: http://blog.csdn.net/AndroidStudioo/article/details/52077597 <br> * author: AndroidStudio 2016-07-31 11:15 <br> * taken by Xin Huang 2017-03-04 15:30 <br> * * @param requestCode integer indicating the kind of action taken by the user * @param resultCode//from w ww. j a v a2s .co m * @param data */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // ImageView image = (ImageView) findViewById(R.id.editImageView); if (data == null) { return; //no data return } if (requestCode == 0) { //get pic from local photo bitmapImage = data.getParcelableExtra("data"); if (bitmapImage == null) {//if pic is not so big use original one try { InputStream inputStream = getContentResolver().openInputStream(data.getData()); bitmapImage = BitmapFactory.decodeStream(inputStream); } catch (FileNotFoundException e) { Intent intent = new Intent(getApplicationContext(), ProfileActivity.class); startActivity(intent); } } } else if (requestCode == 1) { // saveToSDCard(bitmap); try { bitmapImage = (Bitmap) data.getExtras().get("data"); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), ProfileActivity.class); startActivity(intent); finish(); } } else if (resultCode == Activity.RESULT_CANCELED) { try { Intent intent = new Intent(getApplicationContext(), ProfileActivity.class); startActivity(intent); finish(); } catch (Exception e) { } } image.setImageBitmap(bitmapImage); editBitmapImage = bitmapImage; if (editBitmapImage == null) { final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture); deletePicture.setVisibility(View.INVISIBLE); deletePicture.setEnabled(false); } else { final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture); deletePicture.setVisibility(View.VISIBLE); deletePicture.setEnabled(true); } }
From source file:com.stfalcon.contentmanager.ContentManager.java
/** * Process result of camera intent/*from w w w . j a va2 s . co m*/ */ private void onCameraIntentResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { Cursor myCursor = null; Date dateOfPicture = null; try { // Create a Cursor to obtain the file Path for the large image String[] largeFileProjection = { MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.ORIENTATION, MediaStore.Images.ImageColumns.DATE_TAKEN }; String largeFileSort = MediaStore.Images.ImageColumns._ID + " DESC"; myCursor = activity.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, largeFileProjection, null, null, largeFileSort); myCursor.moveToFirst(); if (!myCursor.isAfterLast()) { // This will actually give you the file path location of the image. String largeImagePath = myCursor .getString(myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA)); photoUri = Uri.fromFile(new File(largeImagePath)); if (photoUri != null) { dateOfPicture = new Date(myCursor.getLong( myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATE_TAKEN))); if (dateOfPicture != null && dateOfPicture.after(dateCameraIntentStarted)) { rotateXDegrees = myCursor.getInt( myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION)); } else { photoUri = null; } } if (myCursor.moveToNext() && !myCursor.isAfterLast()) { String largeImagePath3rdLocation = myCursor .getString(myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA)); Date dateOfPicture3rdLocation = new Date(myCursor.getLong( myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATE_TAKEN))); if (dateOfPicture3rdLocation != null && dateOfPicture3rdLocation.after(dateCameraIntentStarted)) { photoUriIn3rdLocation = Uri.fromFile(new File(largeImagePath3rdLocation)); } } } } catch (Exception e) { } finally { if (myCursor != null && !myCursor.isClosed()) { myCursor.close(); } } if (photoUri == null) { try { photoUri = intent.getData(); } catch (Exception e) { } } if (photoUri == null) { photoUri = preDefinedCameraUri; } try { if (photoUri != null && new File(photoUri.getPath()).length() <= 0) { if (preDefinedCameraUri != null) { Uri tempUri = photoUri; photoUri = preDefinedCameraUri; preDefinedCameraUri = tempUri; } } } catch (Exception e) { } photoUri = getFileUriFromContentUri(photoUri); preDefinedCameraUri = getFileUriFromContentUri(preDefinedCameraUri); try { if (photoUriIn3rdLocation != null) { if (photoUriIn3rdLocation.equals(photoUri) || photoUriIn3rdLocation.equals(preDefinedCameraUri)) { photoUriIn3rdLocation = null; } else { photoUriIn3rdLocation = getFileUriFromContentUri(photoUriIn3rdLocation); } } } catch (Exception e) { } if (photoUri != null) { pickContentListener.onContentLoaded(photoUri, Content.IMAGE.toString()); } else { pickContentListener.onError(""); } } else if (resultCode == Activity.RESULT_CANCELED) { pickContentListener.onCanceled(); } else { pickContentListener.onCanceled(); } }
From source file:com.cs4644.vt.theonering.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == kActivityRequestCode_ConnectedActivity) { if (resultCode < 0) { Toast.makeText(this, R.string.scan_unexpecteddisconnect, Toast.LENGTH_LONG).show(); }//w ww . j av a 2 s. c o m } else if (requestCode == kActivityRequestCode_EnableBluetooth) { if (resultCode == Activity.RESULT_OK) { // Bluetooth was enabled, resume scanning resumeScanning(); } else if (resultCode == Activity.RESULT_CANCELED) { AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.setMessage(R.string.dialog_error_no_bluetooth) .setPositiveButton(R.string.dialog_ok, null).show(); DialogUtils.keepDialogOnOrientationChanges(dialog); } } // else if (requestCode == kActivityRequestCode_Settings) { // // Return from activity settings. Update app behaviour if needed // SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // // boolean updatesEnabled = sharedPreferences.getBoolean("pref_updatesenabled", true); // if (updatesEnabled) { // mLatestCheckedDeviceAddress = null; // mFirmwareUpdater.refreshSoftwareUpdatesDatabase(); // } else { // mFirmwareUpdater = null; // } // } }
From source file:com.brandroidtools.filemanager.activities.PickerActivity.java
/** * Method that cancels the activity */ private void cancel() { setResult(Activity.RESULT_CANCELED); finish(); }
From source file:io.strider.camera.CameraLauncher.java
/** * Called when the camera view exits.//w w w. ja va 2s. c o m * * @param requestCode The request code originally supplied to startActivityForResult(), * allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). */ public void onActivityResult(int requestCode, int resultCode, Intent intent) { // Get src and dest types from request code int srcType = (requestCode / 16) - 1; int destType = (requestCode % 16) - 1; int rotate = 0; // If CAMERA if (srcType == CAMERA) { // If image available if (resultCode == Activity.RESULT_OK) { try { // Create an ExifHelper to save the exif data that is lost during compression ExifHelper exif = new ExifHelper(); try { if (this.encodingType == JPEG) { exif.createInFile(getTempDirectoryPath() + "/.Pic.jpg"); exif.readExifData(); rotate = exif.getOrientation(); } } catch (IOException e) { e.printStackTrace(); } Bitmap bitmap = null; Uri uri = null; // If sending base64 image back if (destType == DATA_URL) { bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString())); if (bitmap == null) { // Try to get the bitmap from intent. bitmap = (Bitmap) intent.getExtras().get("data"); } // Double-check the bitmap. if (bitmap == null) { Log.d(LOG_TAG, "I either have a null image path or bitmap"); this.failPicture("Unable to create bitmap!"); return; } if (rotate != 0 && this.correctOrientation) { bitmap = getRotatedBitmap(rotate, bitmap, exif); } this.processPicture(bitmap); checkForDuplicateImage(DATA_URL); } // If sending filename back else if (destType == FILE_URI || destType == NATIVE_URI) { if (this.saveToPhotoAlbum) { Uri inputUri = getUriFromMediaStore(); //Just because we have a media URI doesn't mean we have a real file, we need to make it uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova))); } else { uri = Uri.fromFile( new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg")); } if (uri == null) { this.failPicture("Error capturing image - no media storage found."); } // If all this is true we shouldn't compress the image. if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100 && !this.correctOrientation) { writeUncompressedImage(uri); this.callbackContext.success(uri.toString()); } else { bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString())); if (rotate != 0 && this.correctOrientation) { bitmap = getRotatedBitmap(rotate, bitmap, exif); } // Add compressed version of captured image to returned media store Uri OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); os.close(); // Restore exif data to file if (this.encodingType == JPEG) { String exifPath; if (this.saveToPhotoAlbum) { exifPath = FileHelper.getRealPath(uri, this.cordova); } else { exifPath = uri.getPath(); } exif.createOutFile(exifPath); exif.writeExifData(); } } // Send Uri back to JavaScript for viewing image this.callbackContext.success(uri.toString()); } this.cleanup(FILE_URI, this.imageUri, uri, bitmap); bitmap = null; } catch (IOException e) { e.printStackTrace(); this.failPicture("Error capturing image."); } } // If cancelled else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Camera cancelled."); } // If something else else { this.failPicture("Did not complete!"); } } // // If retrieving photo from library // else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { // if (resultCode == Activity.RESULT_OK) { // Uri uri = intent.getData(); // // // If you ask for video or all media type you will automatically get back a file URI // // and there will be no attempt to resize any returned data // if (this.mediaType != PICTURE) { // this.callbackContext.success(uri.toString()); // } // else { // // This is a special case to just return the path as no scaling, // // rotating, nor compressing needs to be done // if (this.targetHeight == -1 && this.targetWidth == -1 && // (destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation) { // this.callbackContext.success(uri.toString()); // } else { // String uriString = uri.toString(); // // Get the path to the image. Makes loading so much easier. // String mimeType = FileHelper.getMimeType(uriString, this.cordova); // // If we don't have a valid image so quit. // if (!("image/jpeg".equalsIgnoreCase(mimeType) || "image/png".equalsIgnoreCase(mimeType))) { // Log.d(LOG_TAG, "I either have a null image path or bitmap"); // this.failPicture("Unable to retrieve path to picture!"); // return; // } // Bitmap bitmap = null; // try { // bitmap = getScaledBitmap(uriString); // } catch (IOException e) { // e.printStackTrace(); // } // if (bitmap == null) { // Log.d(LOG_TAG, "I either have a null image path or bitmap"); // this.failPicture("Unable to create bitmap!"); // return; // } // // if (this.correctOrientation) { // rotate = getImageOrientation(uri); // if (rotate != 0) { // Matrix matrix = new Matrix(); // matrix.setRotate(rotate); // bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); // } // } // // // If sending base64 image back // if (destType == DATA_URL) { // this.processPicture(bitmap); // } // // // If sending filename back // else if (destType == FILE_URI || destType == NATIVE_URI) { // // Do we need to scale the returned file // if (this.targetHeight > 0 && this.targetWidth > 0) { // try { // // Create an ExifHelper to save the exif data that is lost during compression // String resizePath = getTempDirectoryPath() + "/resize.jpg"; // // Some content: URIs do not map to file paths (e.g. picasa). // String realPath = FileHelper.getRealPath(uri, this.cordova); // ExifHelper exif = new ExifHelper(); // if (realPath != null && this.encodingType == JPEG) { // try { // exif.createInFile(realPath); // exif.readExifData(); // rotate = exif.getOrientation(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // OutputStream os = new FileOutputStream(resizePath); // bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); // os.close(); // // // Restore exif data to file // if (realPath != null && this.encodingType == JPEG) { // exif.createOutFile(resizePath); // exif.writeExifData(); // } // // // The resized image is cached by the app in order to get around this and not have to delete you // // application cache I'm adding the current system time to the end of the file url. // this.callbackContext.success("file://" + resizePath + "?" + System.currentTimeMillis()); // } catch (Exception e) { // e.printStackTrace(); // this.failPicture("Error retrieving image."); // } // } // else { // this.callbackContext.success(uri.toString()); // } // } // if (bitmap != null) { // bitmap.recycle(); // bitmap = null; // } // System.gc(); // } // } // } // else if (resultCode == Activity.RESULT_CANCELED) { // this.failPicture("Selection cancelled."); // } // else { // this.failPicture("Selection did not complete!"); // } // } }
From source file:com.cdvdev.subscriptiondemo.helpers.IabHelper.java
/** * Handles an activity result that's part of the purchase flow in in-app billing. If you * are calling {@link #launchPurchaseFlow}, then you must call this method from your * Activity's {@link android.app.Activity@onActivityResult} method. This method * MUST be called from the UI thread of the Activity. * * @param requestCode The requestCode as you received it. * @param resultCode The resultCode as you received it. * @param data The data (Intent) as you received it. * @return Returns true if the result was related to a purchase flow and was handled; * false if the result was not related to a purchase, in which case you should * handle it normally.//ww w . j av a 2 s . c o m */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { IabResult result; if (requestCode != mRequestCode) return false; checkNotDisposed(); checkSetupDone("handleActivityResult"); // end of async purchase operation that started on launchPurchaseFlow flagEndAsync(); if (data == null) { logError("Null data in IAB activity result."); result = new IabResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } int responseCode = getResponseCodeFromIntent(data); String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE); if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { logDebug("Successful resultcode from purchase activity."); logDebug("Purchase data: " + purchaseData); logDebug("Data signature: " + dataSignature); logDebug("Extras: " + data.getExtras()); logDebug("Expected item type: " + mPurchasingItemType); if (purchaseData == null || dataSignature == null) { logError("BUG: either purchaseData or dataSignature is null."); logDebug("Extras: " + data.getExtras().toString()); result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } Purchase purchase = null; try { purchase = new Purchase(mPurchasingItemType, purchaseData, dataSignature); String sku = purchase.getSku(); // Verify signature if (!Security.verifyPurchase(mLicenseKey, purchaseData, dataSignature)) { logError("Purchase signature verification FAILED for sku " + sku); result = new IabResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase); return true; } logDebug("Purchase signature successfully verified."); } catch (JSONException e) { logError("Failed to parse purchase data."); e.printStackTrace(); result = new IabResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); return true; } if (mPurchaseListener != null) { mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase); } } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode)); if (mPurchaseListener != null) { result = new IabResult(responseCode, "Problem purchashing item."); mPurchaseListener.onIabPurchaseFinished(result, null); } } else if (resultCode == Activity.RESULT_CANCELED) { logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_USER_CANCELLED, "User canceled."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } else { logError("Purchase failed. Result code: " + Integer.toString(resultCode) + ". Response: " + getResponseDesc(responseCode)); result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null); } return true; }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * IMPORTANT: This method must be invoked at the top of the calling * activity's onActivityResult() function or Facebook authentication will * not function properly!//from w w w. ja v a 2s. co m * * If your calling activity does not currently implement onActivityResult(), * you must implement it and include a call to this method if you intend to * use the authorize() method in this SDK. * * For more information, see * http://developer.android.com/reference/android/app/ * Activity.html#onActivityResult(int, int, android.content.Intent) */ public void authorizeCallback(int requestCode, int resultCode, Intent data) { if (requestCode == mAuthActivityCode) { // Successfully redirected. if (resultCode == Activity.RESULT_OK) { // Check OAuth 2.0/2.10 error code. String error = data.getStringExtra("error"); if (error == null) { error = data.getStringExtra("error_type"); } // A Facebook error occurred. if (error != null) { if (error.equals(SINGLE_SIGN_ON_DISABLED) || error.equals("AndroidAuthKillSwitchException")) { Util.logd("Facebook-authorize", "Hosted auth currently " + "disabled. Retrying dialog auth..."); startDialogAuth(mAuthActivity, mAuthPermissions); } else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) { Util.logd("Facebook-authorize", "Login canceled by user."); mAuthDialogListener.onCancel(); } else { String description = data.getStringExtra("error_description"); if (description != null) { error = error + ":" + description; } Util.logd("Facebook-authorize", "Login failed: " + error); mAuthDialogListener.onFacebookError(new FacebookError(error)); } // No errors. } else { setAccessToken(data.getStringExtra(TOKEN)); setAccessExpiresIn(data.getStringExtra(EXPIRES)); if (isSessionValid()) { Util.logd("Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires()); mAuthDialogListener.onComplete(data.getExtras()); } else { mAuthDialogListener.onFacebookError(new FacebookError("Failed to receive access token.")); } } // An error occurred before we could be redirected. } else if (resultCode == Activity.RESULT_CANCELED) { // An Android error occured. if (data != null) { Util.logd("Facebook-authorize", "Login failed: " + data.getStringExtra("error")); mAuthDialogListener.onError(new DialogError(data.getStringExtra("error"), data.getIntExtra("error_code", -1), data.getStringExtra("failing_url"))); // User pressed the 'back' button. } else { Util.logd("Facebook-authorize", "Login canceled by user."); mAuthDialogListener.onCancel(); } } } }
From source file:com.markupartist.sthlmtraveling.PlaceSearchActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_POINT_ON_MAP: if (resultCode != Activity.RESULT_CANCELED) { Site place = data.getParcelableExtra(PointOnMapActivity.EXTRA_STOP); if (!place.hasName()) { place.setName(getString(R.string.point_on_map)); }/*w w w. j a v a 2 s.c om*/ deliverResult(place); } break; } }
From source file:de.qspool.clementineremote.ui.ConnectActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ID_PLAYER_DIALOG) { if (resultCode == Activity.RESULT_CANCELED || resultCode == RESULT_QUIT) { finish();/*from ww w . j a v a2 s . c om*/ } else { doAutoConnect = false; } } else if (requestCode == ID_SETTINGS) { doAutoConnect = false; } else if (requestCode == ID_PERMISSION_REQUEST) { return; } }