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.markupartist.sthlmtraveling.PlannerFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_POINT_ON_MAP_START: if (resultCode == Activity.RESULT_CANCELED) { Log.d(TAG, "action canceled"); } else {/*from w ww .j a v a2 s . c o m*/ mStartPoint = data.getParcelableExtra(PointOnMapActivity.EXTRA_STOP); mStartPointAutoComplete.setText(getText(R.string.point_on_map)); // mStartPointAutoComplete.setText(mStartPoint.getName()); Log.d(TAG, "Got Stop " + mStartPoint); } break; case REQUEST_CODE_POINT_ON_MAP_END: if (resultCode == Activity.RESULT_CANCELED) { Log.d(TAG, "action canceled"); } else { mEndPoint = data.getParcelableExtra(PointOnMapActivity.EXTRA_STOP); mEndPointAutoComplete.setText(getText(R.string.point_on_map)); // mEndPointAutoComplete.setText(mEndPoint.getName()); Log.d(TAG, "Got Stop " + mEndPoint); } break; } }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java
@Override public void onFinishDiagnosticResultDialog(boolean retry, boolean cancelled, String result, boolean isCalibration) { mResultFragment.dismiss();//from ww w. j a va2 s . co m if (mHighLevelsFound && !isCalibration) { mCameraFragment.dismiss(); sound.playShortResource(R.raw.beep_long); String title = CaddisflyApp.getApp().getCurrentTestInfo().getName(); String message; //todo: remove hard coding of dilution levels switch (mDilutionLevel) { case 0: message = String.format(getString(R.string.tryWithDilutedSample), 2); break; case 1: message = String.format(getString(R.string.tryWithDilutedSample), 5); break; default: message = EMPTY_STRING; } ResultDialogFragment mResultDialogFragment = ResultDialogFragment.newInstance(title, result, mDilutionLevel, message, CaddisflyApp.getApp().getCurrentTestInfo().getUnit()); final FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment fragment = getFragmentManager().findFragmentByTag(RESULT_DIALOG_TAG); if (fragment != null) { ft.remove(fragment); } mResultDialogFragment.setCancelable(false); mResultDialogFragment.show(ft, RESULT_DIALOG_TAG); } else if (retry) { mCameraFragment.dismiss(); initializeTest(); } else { releaseResources(); if (cancelled) { setResult(Activity.RESULT_CANCELED); } else { setResultIntent(); } finish(); } }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java
@Override public void dialogCancelled() { Intent intent = new Intent(getIntent()); intent.putExtra(SensorConstants.RESPONSE, String.valueOf(EMPTY_STRING)); this.setResult(Activity.RESULT_CANCELED, intent); releaseResources();//from w w w. java 2s . c o m finish(); }
From source file:org.creativecommons.thelist.fragments.MyListFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { prepForPhotoUpload(data);/*from ww w .j a v a2 s . c o m*/ final Resources res = getResources(); final String[] choices = res.getStringArray(R.array.single_choice_terms_array); String title = null; String content = res.getString(R.string.single_choice_terms_content); switch (requestCode) { case PhotoConstants.PICK_PHOTO_REQUEST: title = res.getString(R.string.single_choice_choose_photo_title); break; case PhotoConstants.TAKE_PHOTO_REQUEST: title = res.getString(R.string.single_choice_take_photo_title); break; } //switch mMessageHelper.showSingleChoiceDialog(mContext, title, content, choices, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { if (charSequence == (choices[0])) { //Positive response startPhotoUpload(); } else { //Negative response showUploadCancelledSnackbar(); } return true; } }); } else if (resultCode != Activity.RESULT_CANCELED) { //result other than ok or cancelled // Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show(); Log.d(TAG, "> onActivityResult > resultCode != canceled"); } }
From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { // Check for the integer request code originally supplied to startResolutionForResult(). case REQUEST_CHECK_SETTINGS: mIsAlreadyShownDialog = false;//from w w w. ja v a2 s. c om switch (resultCode) { case Activity.RESULT_OK: Log.i(TAG, "User agreed to make required location settings changes."); //startLocationUpdates(); break; case Activity.RESULT_CANCELED: Log.i(TAG, "User chose not to make required location settings changes."); break; } break; case Constants.START_ACTIVITY_REQUEST_CHECK_TTS_DATA: if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { // check korean mText2Speech = new TextToSpeech(this, this); } else { Log.d(TAG, " ??.... ? ??..."); if (mcheckText2SpeechLister != null) { mcheckText2SpeechLister.onCheckResult(null); mText2Speech = null; } showText2SpeechAlertDialog(); LauncherSettings.getInstance(this).setIsCheckedTTSEngine(true); } break; } }
From source file:com.nextgis.ngm_clink_monitoring.fragments.CreateObjectFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { File tempPhotoFile = new File(mTempPhotoPath); if (requestCode == REQUEST_TAKE_PHOTO && resultCode == Activity.RESULT_OK) { Location currLocation = mGpsEventSource.getLastKnownLocation(); float dist = mAccurateLocation.distanceTo(currLocation); if (dist > FoclConstants.MAX_DISTANCE_FROM_OBJECT_TO_PHOTO) { if (tempPhotoFile.delete()) { Log.d(TAG, "tempPhotoFile deleted on Activity.RESULT_OK and bad coordinates, path: " + tempPhotoFile.getAbsolutePath()); YesNoDialog dialog = new YesNoDialog(); dialog.setKeepInstance(true).setIcon(R.drawable.ic_action_warning) .setTitle(R.string.photo_not_saved).setMessage(R.string.photo_not_saved_distance_exceed) .setPositiveText(R.string.ok) .setOnPositiveClickedListener(new YesNoDialog.OnPositiveClickedListener() { @Override public void onPositiveClicked() { // cancel }//from w ww .ja v a2 s .c om }).show(getActivity().getSupportFragmentManager(), FoclConstants.FRAGMENT_YES_NO_DIALOG + "PhotoNotSaved"); } else { Log.d(TAG, "tempPhotoFile delete FAILED on Activity.RESULT_OK and bad coordinates, path: " + tempPhotoFile.getAbsolutePath()); } } else { setPhotoGalleryAdapter(); setPhotoGalleryVisibility(true); } } if (requestCode == REQUEST_TAKE_PHOTO && resultCode == Activity.RESULT_CANCELED) { if (tempPhotoFile.delete()) { Log.d(TAG, "tempPhotoFile deleted on Activity.RESULT_CANCELED, path: " + tempPhotoFile.getAbsolutePath()); } else { Log.d(TAG, "tempPhotoFile delete FAILED on Activity.RESULT_CANCELED, path: " + tempPhotoFile.getAbsolutePath()); } } }
From source file:com.TagFu.facebook.Session.java
/** * Provides an implementation for {@link Activity#onActivityResult onActivityResult} that updates the Session based * on information returned during the authorization flow. The Activity that calls open or requestNewPermissions * should forward the resulting onActivityResult call here to update the Session state based on the contents of the * resultCode and data.// w ww.ja va2 s . c om * * @param currentActivity The Activity that is forwarding the onActivityResult call. * @param requestCode The requestCode parameter from the forwarded call. When this onActivityResult occurs as part * of Facebook authorization flow, this value is the activityCode passed to open or authorize. * @param resultCode An int containing the resultCode parameter from the forwarded call. * @param data The Intent passed as the data parameter from the forwarded call. * @return A boolean indicating whether the requestCode matched a pending authorization request for this Session. */ public final boolean onActivityResult(final Activity currentActivity, final int requestCode, final int resultCode, final Intent data) { Validate.notNull(currentActivity, "currentActivity"); initializeStaticContext(currentActivity); synchronized (this.lock) { if ((this.pendingAuthorizationRequest == null) || (requestCode != this.pendingAuthorizationRequest.getRequestCode())) { return false; } } Exception exception = null; AuthorizationClient.Result.Code code = AuthorizationClient.Result.Code.ERROR; if (data != null) { final AuthorizationClient.Result result = (AuthorizationClient.Result) data .getSerializableExtra(LoginActivity.RESULT_KEY); if (result != null) { // This came from LoginActivity. this.handleAuthorizationResult(resultCode, result); return true; } else if (this.authorizationClient != null) { // Delegate to the auth client. this.authorizationClient.onActivityResult(requestCode, resultCode, data); return true; } } else if (resultCode == Activity.RESULT_CANCELED) { exception = new FacebookOperationCanceledException("User canceled operation."); code = AuthorizationClient.Result.Code.CANCEL; } if (exception == null) { exception = new FacebookException("Unexpected call to Session.onActivityResult"); } this.logAuthorizationComplete(code, null, exception); this.finishAuthOrReauth(null, exception); return true; }
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
/** * Called when the camera view exits.// ww w . j a v a2 s . 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; Log.d(LOG_TAG, "-z"); // If retrieving photo from library if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { Log.d(LOG_TAG, "-y"); if (resultCode == Activity.RESULT_OK) { Log.d(LOG_TAG, "-x"); Uri uri = intent.getData(); Log.d(LOG_TAG, "-w"); // 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) { Log.d(LOG_TAG, "mediaType not PICTURE, so must be Video"); String metadataDateTime = ""; ExifInterface exif; try { exif = new ExifInterface(this.getRealPathFromURI(uri, this.cordova)); if (exif.getAttribute(ExifInterface.TAG_DATETIME) != null) { Log.d(LOG_TAG, "z4a"); metadataDateTime = exif.getAttribute(ExifInterface.TAG_DATETIME).toString(); metadataDateTime = metadataDateTime.replaceFirst(":", "-"); metadataDateTime = metadataDateTime.replaceFirst(":", "-"); } } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } Log.d(LOG_TAG, "before create thumbnail"); Bitmap bitmap = ThumbnailUtils.createVideoThumbnail( (new File(this.getRealPathFromURI(uri, this.cordova))).getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND); Log.d(LOG_TAG, "after create thumbnail"); String mid = generateRandomMid(); try { String filePathMedium = this.getTempDirectoryPath(this.cordova.getActivity()) + "/medium_" + mid + ".jpg"; FileOutputStream foMedium = new FileOutputStream(filePathMedium); bitmap.compress(CompressFormat.JPEG, 100, foMedium); foMedium.flush(); foMedium.close(); bitmap.recycle(); System.gc(); JSONObject mediaFile = new JSONObject(); try { mediaFile.put("mid", mid); mediaFile.put("mediaType", "video"); mediaFile.put("filePath", filePathMedium); mediaFile.put("filePathMedium", filePathMedium); mediaFile.put("filePathThumb", filePathMedium); mediaFile.put("typeOfPluginResult", "initialRecordInformer"); String absolutePath = (new File(this.getRealPathFromURI(uri, this.cordova))) .getAbsolutePath(); mediaFile.put("fileExt", absolutePath.substring(absolutePath.lastIndexOf(".") + 1)); if (metadataDateTime != "") { mediaFile.put("metadataDateTime", metadataDateTime); } } catch (JSONException e) { Log.d(LOG_TAG, "error: " + e.getStackTrace().toString()); } Log.d(LOG_TAG, "mediafile at 638" + mediaFile.toString()); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, (new JSONArray()).put(mediaFile)); pluginResult.setKeepCallback(true); this.callbackContext.sendPluginResult(pluginResult); new UploadVideoToS3Task().execute(new File(this.getRealPathFromURI(uri, this.cordova)), this.callbackContext, mid, mediaFile); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } else { String imagePath = this.getRealPathFromURI(uri, this.cordova); String mimeType = FileUtils.getMimeType(imagePath); // If we don't have a valid image so quit. if (imagePath == null || mimeType == null || !(mimeType.equalsIgnoreCase("image/jpeg") || mimeType.equalsIgnoreCase("image/png"))) { Log.d(LOG_TAG, "I either have a null image path or bitmap"); this.failPicture("Unable to retrieve path to picture!"); return; } String mid = generateRandomMid(); Log.d(LOG_TAG, "a"); JSONObject mediaFile = new JSONObject(); Log.d(LOG_TAG, "b"); try { FileInputStream fi = new FileInputStream(imagePath); Bitmap bitmap = BitmapFactory.decodeStream(fi); fi.close(); Log.d(LOG_TAG, "z1"); // try to get exif data ExifInterface exif = new ExifInterface(imagePath); Log.d(LOG_TAG, "z2"); JSONObject metadataJson = new JSONObject(); Log.d(LOG_TAG, "z3"); /* JSONObject latlng = new JSONObject(); String lat = "0"; String lng = "0"; if (exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) != null) { lat = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); } if (exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE) != null) { lng = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); } latlng.put("lat", lat); latlng.put("lng", lng); Log.d(LOG_TAG, "z4"); metadataJson.put("locationData", latlng); */ String metadataDateTime = ""; if (exif.getAttribute(ExifInterface.TAG_DATETIME) != null) { Log.d(LOG_TAG, "z4a"); JSONObject exifWrapper = new JSONObject(); exifWrapper.put("DateTimeOriginal", exif.getAttribute(ExifInterface.TAG_DATETIME).toString()); exifWrapper.put("DateTimeDigitized", exif.getAttribute(ExifInterface.TAG_DATETIME).toString()); metadataDateTime = exif.getAttribute(ExifInterface.TAG_DATETIME).toString(); metadataDateTime = metadataDateTime.replaceFirst(":", "-"); metadataDateTime = metadataDateTime.replaceFirst(":", "-"); Log.d(LOG_TAG, "z5"); metadataJson.put("Exif", exifWrapper); } Log.d(LOG_TAG, "z6"); Log.d(LOG_TAG, "metadataJson: " + metadataJson.toString()); Log.d(LOG_TAG, "metadataDateTime: " + metadataDateTime.toString()); if (exif.getAttribute(ExifInterface.TAG_ORIENTATION) != null) { int o = Integer.parseInt(exif.getAttribute(ExifInterface.TAG_ORIENTATION)); Log.d(LOG_TAG, "z7"); if (o == ExifInterface.ORIENTATION_NORMAL) { rotate = 0; } else if (o == ExifInterface.ORIENTATION_ROTATE_90) { rotate = 90; } else if (o == ExifInterface.ORIENTATION_ROTATE_180) { rotate = 180; } else if (o == ExifInterface.ORIENTATION_ROTATE_270) { rotate = 270; } else { rotate = 0; } Log.d(LOG_TAG, "z8"); Log.d(LOG_TAG, "rotate: " + rotate); // try to correct orientation if (rotate != 0) { Matrix matrix = new Matrix(); Log.d(LOG_TAG, "z9"); matrix.setRotate(rotate); Log.d(LOG_TAG, "z10"); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); Log.d(LOG_TAG, "z11"); } } Log.d(LOG_TAG, "c"); String filePath = this.getTempDirectoryPath(this.cordova.getActivity()) + "/econ_" + mid + ".jpg"; FileOutputStream foEcon = new FileOutputStream(filePath); fitInsideSquare(bitmap, 850).compress(CompressFormat.JPEG, 45, foEcon); foEcon.flush(); foEcon.close(); Log.d(LOG_TAG, "d"); String filePathMedium = this.getTempDirectoryPath(this.cordova.getActivity()) + "/medium_" + mid + ".jpg"; FileOutputStream foMedium = new FileOutputStream(filePathMedium); makeInsideSquare(bitmap, 320).compress(CompressFormat.JPEG, 55, foMedium); foMedium.flush(); foMedium.close(); Log.d(LOG_TAG, "e"); String filePathThumb = this.getTempDirectoryPath(this.cordova.getActivity()) + "/thumb_" + mid + ".jpg"; FileOutputStream foThumb = new FileOutputStream(filePathThumb); makeInsideSquare(bitmap, 175).compress(CompressFormat.JPEG, 55, foThumb); foThumb.flush(); foThumb.close(); bitmap.recycle(); System.gc(); Log.d(LOG_TAG, "f"); mediaFile.put("mid", mid); mediaFile.put("mediaType", "photo"); mediaFile.put("filePath", filePath); mediaFile.put("filePathMedium", filePath); mediaFile.put("filePathThumb", filePath); mediaFile.put("typeOfPluginResult", "initialRecordInformer"); //mediaFile.put("metadataJson", metadataJson); if (metadataDateTime != "") { mediaFile.put("metadataDateTime", metadataDateTime); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, (new JSONArray()).put(mediaFile)); pluginResult.setKeepCallback(true); this.callbackContext.sendPluginResult(pluginResult); Log.d(LOG_TAG, "g"); Log.d(LOG_TAG, "mediaFile " + mediaFile.toString()); new UploadFilesToS3Task().execute(new File(filePath), new File(filePathMedium), new File(filePathThumb), this.callbackContext, mid, mediaFile); Log.d(LOG_TAG, "h"); } catch (FileNotFoundException e) { Log.d(LOG_TAG, "error: " + e.getStackTrace().toString()); } catch (IOException e1) { // TODO Auto-generated catch block Log.d(LOG_TAG, "error: " + e1.getStackTrace().toString()); } catch (JSONException e2) { // TODO Auto-generated catch block Log.d(LOG_TAG, "error: " + e2.getStackTrace().toString()); } /* if (this.correctOrientation) { String[] cols = { MediaStore.Images.Media.ORIENTATION }; Cursor cursor = this.cordova .getActivity() .getContentResolver() .query(intent.getData(), cols, null, null, null); if (cursor != null) { cursor.moveToPosition(0); rotate = cursor.getInt(0); cursor.close(); } if (rotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(rotate); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } } // Create an ExifHelper to save the exif // data that is lost during compression String resizePath = this .getTempDirectoryPath(this.cordova .getActivity()) + "/resize.jpg"; ExifHelper exif = new ExifHelper(); try { if (this.encodingType == JPEG) { exif.createInFile(resizePath); 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 (this.encodingType == JPEG) { exif.createOutFile(this .getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); } if (bitmap != null) { bitmap.recycle(); bitmap = null; } System.gc(); // The resized image is cached by the app in // order to get around this and not have to // delete your // application cache I'm adding the current // system time to the end of the file url. this.callbackContext.success("file://" + resizePath + "?" + System.currentTimeMillis()); */ } } else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Selection cancelled."); } else { this.failPicture("Selection did not complete!"); } } }
From source file:io.puzzlebox.bloom.ui.BloomFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // User chose not to enable Bluetooth. if (requestCode == BloomSingleton.getInstance().REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) { getActivity().finish();/* w w w .jav a 2 s . com*/ return; } super.onActivityResult(requestCode, resultCode, data); }