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:justforcommunity.radiocom.activities.Home.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if ((resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_CANCELED) && requestCode == AUTH_REQUEST) { updateUserInfo();/* w ww. j a va2 s. co m*/ } }
From source file:com.barbrdo.app.activities.SignUpActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CHECK_SETTINGS: switch (resultCode) { case Activity.RESULT_OK: Log.i(TAG, "User agreed to make required location settings changes."); startLocationUpdates();/* w w w .ja v a 2 s .co m*/ break; case Activity.RESULT_CANCELED: Log.i(TAG, "User chose not to make required location settings changes."); mRequestingLocationUpdates = false; finish(); break; } break; } }
From source file:com.zologic.tardis.app.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(); }//from w ww.j ava2 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:org.onepf.life2.oms.appstore.googleUtils.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.//from w w w .j a v a2 s . c o m */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { IabResult result; if (requestCode != mRequestCode) return false; checkSetupDone("handleActivityResult"); // end of async purchase operation 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) { processPurchaseSuccess(data, purchaseData, dataSignature); } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. processPurchaseFail(responseCode); } 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:com.granita.tasks.EditTaskFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final int menuId = item.getItemId(); Activity activity = getActivity();/* w ww .j av a 2 s . c o m*/ if (menuId == R.id.editor_action_save) { saveAndExit(); return true; } else if (menuId == R.id.editor_action_cancel) { activity.setResult(Activity.RESULT_CANCELED); activity.finish(); return true; } return false; }
From source file:com.filterdevice.ProfileScanningFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // User chose not to enable BlueTooth. if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) { getActivity().finish();/* w w w .j av a 2 s .com*/ } else { // Check which request we're responding to if (requestCode == REQUEST_ENABLE_BT) { // Make sure the request was successful if (resultCode == Activity.RESULT_OK) { Toast.makeText(getActivity(), getResources().getString(R.string.device_bluetooth_on), Toast.LENGTH_SHORT).show(); mLeDeviceListAdapter = new LeDeviceListAdapter(); mProfileListView.setAdapter(mLeDeviceListAdapter); scanLeDevice(true); } else { getActivity().finish(); } } } }
From source file:com.tuxpan.foregroundcameragalleryplugin.ForegroundCameraLauncher.java
/** * Called when the camera view exits./*from w w w . ja va 2 s. c om*/ * * @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); RotateTask r = new RotateTask(bitmap, srcType, destType, rotate, intent); r.execute(); return; } } returnImageToProcess(bitmap, srcType, destType, intent, rotate); } } } else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Selection cancelled."); } else { this.failPicture("Selection did not complete!"); } } }
From source file:com.example.nachiketvatkar.locateus.BluetoothPairing.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(); }//from w ww . ja v a2 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.google.plus.samples.photohunt.PlusClientFragment.java
public boolean handleOnActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != mRequestCode) { return false; }/*from w ww. j a v a2 s. c o m*/ switch (resultCode) { case Activity.RESULT_OK: mLastConnectionResult = null; mPlusClient.connect(); mIsConnecting = true; break; case Activity.RESULT_CANCELED: // User canceled sign in, clear the request code. mRequestCode = INVALID_REQUEST_CODE; break; } return true; }
From source file:io.romain.passport.ui.AddCityActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_CHECK_SETTINGS: switch (resultCode) { case Activity.RESULT_OK: // All required changes were successfully made Dog.i("User agreed to make required location settings changes."); getUserLocation();/*from w ww .j a va2 s . c om*/ break; case Activity.RESULT_CANCELED: // The user was asked to change settings, but chose not Dog.i("User chose not to make required location settings changes."); hideLocationIcon(); default: break; } break; } }