List of usage examples for android.app Activity RESULT_OK
int RESULT_OK
To view the source code for android.app Activity RESULT_OK.
Click Source Link
From source file:com.bloc.blocparty.TimelineFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && requestCode >= 0 /* * && * requestCode < * listElements * .size() */) { Log.d(TAG, "photo submit button pressed"); uploadPhoto();/*from w w w. j av a 2 s. c o m*/ } else { // This means to re-authenticate uiHelper.onActivityResult(requestCode, resultCode, data, nativeDialogCallback); } // For camera if (requestCode == CAMERA_TAKE_PHOTO_REQUEST_CODE) { if (resultCode == RESULT_OK) { // -1 // successfully captured the image // display it in image view bm = BitmapFactory.decodeFile(mCurrentPhotoPath); try { if (fileUri != null) { photoUri = fileUri; Log.d(TAG, "Image saved to:\n" + photoUri); Log.d(TAG, "Image path:\n" + photoUri.getPath()); Log.d(TAG, "Image name:\n" + photoUri.getLastPathSegment());// getName(fileUri)); PictureSubmitFragment picSubmitFragment = new PictureSubmitFragment(); picSubmitFragment.setSubmitPhotoAndFileName(bm, photoUri); picSubmitFragment.setTargetFragment(this, PHOTO_SUBMIT); picSubmitFragment.show(getFragmentManager(), "fragment_picture_submit"); } else if (data != null) { photoUri = data.getData(); } else if (resultCode == RESULT_CANCELED) { // 0 // user cancelled Image capture } else { // failed to capture image } } catch (Exception e) { e.printStackTrace(); } } } }
From source file:most.voip.example.remote_config.MainActivity.java
public void acceptConfig(View view) { Intent resultIntent = new Intent(); Bundle b = new Bundle(); b.putString("account_data", accountDetailsData); b.putString("buddies_data", buddiesDetailsData); resultIntent.putExtras(b);//from ww w. j a va 2 s .com // TODO Add extras or a data URI to this intent as appropriate. Log.d(TAG, "Configuration accepted"); setResult(Activity.RESULT_OK, resultIntent); finish(); }
From source file:com.intel.xdk.camera.Camera.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == SELECT_PICTURE) { imageSelected(data);/*from ww w . jav a 2s.c om*/ } else { //get info from shared prefs SharedPreferences prefs = activity.getSharedPreferences(cameraPrefsKey, 0); String outputFile = prefs.getString(cameraPrefsFileName, ""); boolean isPNG = prefs.getBoolean(cameraPrefsIsPNG, false); int quality = prefs.getInt(cameraPrefsQuality, 100); savePicture(outputFile, quality, isPNG); } } else { pictureCancelled(); } }
From source file:com.cloudstudio.camera.ForegroundCameraLauncher.java
/** * Called when the camera view exits./*from w ww. j a va 2s . 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) { // 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(); exif.createInFile( getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg"); exif.readExifData(); // Read in bitmap of captured image Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri); } catch (FileNotFoundException e) { Uri uri = intent.getData(); android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver(); bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); } bitmap = scaleBitmap(bitmap); // Create entry in media store for image // (Don't use insertImage() because it uses default compression // setting of 50 - no way to change it) ContentValues values = new ContentValues(); values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); Uri uri = null; try { Log.d("camera", "external_content_uri:" + android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); uri = this.cordova.getActivity().getContentResolver() .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { LOG.d(LOG_TAG, "Can't write to external media storage."); try { uri = this.cordova.getActivity().getContentResolver() .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException ex) { LOG.d(LOG_TAG, "Can't write to internal media storage."); this.failPicture("Error capturing image - no media storage found."); return; } } Log.d("camera", "uri:" + uri.toString()); // 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 exif.createOutFile(getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); // Send Uri back to JavaScript for viewing image this.callbackContext.success(getRealPathFromURI(uri, this.cordova)); bitmap.recycle(); bitmap = null; System.gc(); checkForDuplicateImage(); } 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!"); } }
From source file:com.paymaya.sdk.android.checkout.PayMayaCheckoutActivity.java
private void finishSuccess() { Intent intent = new Intent(); setResult(Activity.RESULT_OK, intent); finish(); }
From source file:com.mifos.mifosxdroid.online.ClientDetailsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == Activity.RESULT_OK) uploadImage(capturedClientImageFile); }
From source file:org.mifos.androidclient.main.CustomerDetailsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case ApplyCustomerChargeActivity.REQUEST_CODE: switch (resultCode) { case Activity.RESULT_OK: runCustomerDetailsTask();//from w ww. j av a 2 s. co m break; case Activity.RESULT_CANCELED: break; default: break; } break; default: break; } }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) { final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT); new StringInputParser(input) { @Override//from w w w . j a v a2 s.c o m protected void handlePaymentIntent(@Nonnull final PaymentIntent paymentIntent) { SendCoinsActivity.start(WalletActivity.this, paymentIntent); } @Override protected void handleDirectTransaction(final Transaction tx) throws VerificationException { application.processDirectTransaction(tx); } @Override protected void error(final int messageResId, final Object... messageArgs) { dialog(WalletActivity.this, null, R.string.button_scan, messageResId, messageArgs); } }.parse(); } }
From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) { final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT); new StringInputParser(input) { @Override// w ww. j ava2 s. c o m protected void handlePaymentIntent(@Nonnull final PaymentIntent paymentIntent) { SendCoinsActivity.start(WalletActivity.this, paymentIntent); } @Override protected void handlePrivateKey(@Nonnull final ECKey key) { SweepWalletActivity.start(WalletActivity.this, key); } @Override protected void handleDirectTransaction(final Transaction tx) throws VerificationException { application.processDirectTransaction(tx); } @Override protected void error(final int messageResId, final Object... messageArgs) { dialog(WalletActivity.this, null, R.string.button_scan, messageResId, messageArgs); } }.parse(); } if (requestCode == REQUEST_CODE_SCAN_ADD_CONTACT && resultCode == Activity.RESULT_OK) { addContactScanResult = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT); } if (requestCode == REQUEST_PICK_BACKUP && resultCode == Activity.RESULT_OK) { pickBackupResult = intent.getData(); } }
From source file:nf.frex.android.FrexActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return;//from w w w.j a v a 2s . c o m } if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) { final Uri imageUri = data.getData(); if (imageUri != null) { File imageFile = new File(imageUri.getPath()); String configName = FrexIO.getFilenameWithoutExt(imageFile); File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT); try { FileInputStream fis = new FileInputStream(paramFile); try { readFrexDoc(fis, configName); } finally { fis.close(); } } catch (IOException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == R.id.settings) { view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this)); } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) { final Uri imageUri = data.getData(); final ColorQuantizer colorQuantizer = new ColorQuantizer(); final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } colorQuantizer.cancel(); } }; final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() { @Override public void progress(final String msg, final int iter, final int maxIter) { runOnUiThread(new Runnable() { @Override public void run() { progressDialog.setMessage(msg); progressDialog.setProgress(iter); } }); } }; progressDialog.setTitle(getString(R.string.get_pal_from_img_title)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(cancelListener); progressDialog.setMax(colorQuantizer.getMaxIterCount()); progressDialog.show(); Thread thread = new Thread(new Runnable() { @Override public void run() { Bitmap bitmap; try { bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256); } catch (IOException e) { alert("I/O error: " + e.getLocalizedMessage()); return; } ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener); progressDialog.dismiss(); if (colorScheme != null) { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme"); String colorSchemeId = "$" + imageUri.toString(); colorSchemes.add(colorSchemeId, colorScheme); view.setColorSchemeId(colorSchemeId); view.setColorScheme(colorScheme); view.recomputeColors(); runOnUiThread(new Runnable() { @Override public void run() { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)"); showDialog(R.id.colors); } }); } } }); thread.start(); } }