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:be.ppareit.swiftp.gui.PreferenceFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent resultData) { if (requestCode == ACTION_OPEN_DOCUMENT_TREE && resultCode == Activity.RESULT_OK) { Uri treeUri = resultData.getData(); String path = treeUri.getPath(); final CheckBoxPreference writeExternalStorage_pref = findPref("writeExternalStorage"); if (!":".equals(path.substring(path.length() - 1)) || path.contains("primary")) { writeExternalStorage_pref.setChecked(false); } else {/* www .j av a 2 s.co m*/ FsSettings.setExternalStorageUri(treeUri.toString()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getActivity().getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } writeExternalStorage_pref.setChecked(true); } } }
From source file:com.lepin.activity.CarDriverVerify.java
/** * TODO/*from www . j a v a 2 s .c o m*/ */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) return; Bitmap bitmap = null; if (requestCode == CAMERA_RESULT) { path = util.getPath(carId, PhoteName[i], CarDriverVerify.this); bitmap = Util.getInstance().getSmallBitmap(CarDriverVerify.this, path); boolean flag = Util.getInstance().save(CarDriverVerify.this, path, bitmap); } else if (requestCode == IMAGE_RESULT) { Uri selectedImage = data.getData(); if (!String.valueOf(selectedImage).startsWith("content:")) { Util.showToast(CarDriverVerify.this, "??"); } else { path = Util.getInstance().getImagePath(CarDriverVerify.this, selectedImage); bitmap = Util.getInstance().getSmallBitmap(CarDriverVerify.this, path); Util.getInstance().save(CarDriverVerify.this, pathString[i], bitmap); } } if (null != bitmap) { imageViews[i].setImageBitmap(bitmap); } }
From source file:com.github.socialc0de.gsw.android.MainActivity.java
/** * Handles the results from activities launched to select an account and to install Google Play * Services.//from w w w. j a v a2s .co m */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_ACCOUNT_PICKER: if (data != null && data.getExtras() != null) { String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { onSignedIn(accountName); } } else if (!SIGN_IN_REQUIRED) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.are_you_sure); alert.setMessage(R.string.not_all_features); alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startMainActivity(); } }); alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); } }); alert.show(); } break; case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode != Activity.RESULT_OK) { checkGooglePlayServicesAvailable(); } break; } 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)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG).show(); } 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."); } } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("FuturePaymentExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("FuturePaymentExample", authorization_code); Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("FuturePaymentExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("FuturePaymentExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("ProfileSharingExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("ProfileSharingExample", authorization_code); Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("ProfileSharingExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("ProfileSharingExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } }
From source file:cordova.plugin.RequestLocationAccuracy.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.i(TAG, "onActivityResult()"); switch (requestCode) { // Check for the integer request code originally supplied to startResolutionForResult(). case REQUEST_CHECK_SETTINGS: switch (resultCode) { case Activity.RESULT_OK: String msg = "User agreed to make required location settings changes."; Log.i(TAG, msg);//from ww w .j ava 2s . c o m handleSuccess(msg, SUCCESS_USER_AGREED); break; case Activity.RESULT_CANCELED: handleError("User chose not to make required location settings changes.", ERROR_USER_DISAGREED); break; } break; } }
From source file:com.orbar.pxdemo.MainActivity.java
/** * receives the result of a successful login and starts the login actions *///from ww w .ja v a 2 s .c om @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == Activity.RESULT_OK) { onSuccessLogin(); } if (resultCode == Activity.RESULT_CANCELED) { Log.e(TAG, "Unable to login"); } } }
From source file:li.barter.fragments.AddOrEditBookFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (requestCode == AppConstants.RequestCodes.LOGIN_TO_ADD_BOOK) { if (resultCode == Activity.RESULT_OK) { checkAndFinishBookSubmitTask(); }//from w w w . j a va 2 s . c o m } else { super.onActivityResult(requestCode, resultCode, data); } }
From source file:cis350.blanket.IntentIntegrator.java
/** * <p>Call this from your {@link Activity}'s * {@link Activity#onActivityResult(int, int, Intent)} method.</p> * * @param requestCode request code from {@code onActivityResult()} * @param resultCode result code from {@code onActivityResult()} * @param intent {@link Intent} from {@code onActivityResult()} * @return null if the event handled here was not related to this class, or * else an {@link IntentResult} containing the result of the scan. If the user cancelled scanning, * the fields will be null.//w w w .j a v a 2 s . com */ public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { String contents = intent.getStringExtra("SCAN_RESULT"); String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT"); byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES"); int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE); Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation; String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL"); return new IntentResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel); } return new IntentResult(); } return null; }
From source file:com.karura.framework.plugins.Capture.java
/** * Called when the video view exits.//w w w . j a v a 2 s . co 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"). * @throws JSONException */ public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { final String callId = requestCallIdMap.get(requestCode); final ContentResolver cr = getContext().getContentResolver(); if (callId == null) { return; } requestCallIdMap.remove(requestCode); runInBackground(new Runnable() { public void run() { // Result received okay if (resultCode == Activity.RESULT_OK) { // An audio clip was requested if (requestCode == CAPTURE_AUDIO) { // Get the uri of the audio clip Uri data = intent.getData(); // create a file object from the uri results.put(createMediaFile(data)); // Send Uri back to JavaScript for listening to audio resolveWithResult(callId, results); } else if (requestCode == CAPTURE_IMAGE) { // For some reason if I try to do: // Uri data = intent.getData(); // It crashes in the emulator and on my phone with a null pointer exception // To work around it I had to grab the code from CameraLauncher.java try { // 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(MIME_TYPE, IMAGE_JPEG); Uri uri = null; try { uri = cr.insert(EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { Log.d(LOG_TAG, "Can't write to external media storage."); try { uri = cr.insert(INTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException ex) { Log.d(LOG_TAG, "Can't write to internal media storage."); reject(callId, CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found."); return; } } FileInputStream fis = new FileInputStream( DirectoryManager.getTempDirectoryPath(getContext()) + "/Capture.jpg"); OutputStream os = cr.openOutputStream(uri); byte[] buffer = new byte[4096]; int len; while ((len = fis.read(buffer)) != -1) { os.write(buffer, 0, len); } os.flush(); os.close(); fis.close(); // Add image to results results.put(createMediaFile(uri)); checkForDuplicateImage(); // Send Uri back to JavaScript for viewing image resolveWithResult(callId, results); } catch (IOException e) { if (BuildConfig.DEBUG) { e.printStackTrace(); } reject(callId, CAPTURE_INTERNAL_ERR, "Error capturing image."); } } else if (requestCode == CAPTURE_VIDEO) { // Get the uri of the video clip Uri data = intent.getData(); // create a file object from the uri results.put(createMediaFile(data)); // Send Uri back to JavaScript for viewing video resolveWithResult(callId, results); } } // if cancelled or something else else { // user canceled the action rejectWithError(callId, CAPTURE_NO_MEDIA_FILES, "Canceled."); } } }); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PERFORM_ACTIONS: mActivityCallback.onFinished();/*from ww w . j a va 2 s. com*/ break; case ACTIVITY_REQUEST_FILE: if (data != null && resultCode == Activity.RESULT_OK) { mSelectedFile = FileUtils.getPathFromUri(getActivity(), data.getData()); GenericProgressDialog d = GenericProgressDialog .newInstance(R.string.zip_flashing_dialog_verifying_zip, R.string.please_wait); d.show(getFragmentManager(), PROGRESS_DIALOG_VERIFY_ZIP); if (mService != null) { verifyZip(); } else { mVerifyZipOnServiceConnected = true; } } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.example.bluetooth_faster_connection.MainActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (D)// www . j a va2s. c om Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE_SECURE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, true); } break; case REQUEST_CONNECT_DEVICE_INSECURE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, false); } break; case REQUEST_CONNECT_DEVICE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, false); } break; case REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { // Bluetooth is now enabled, so set up a Message session setupMessage(); } else { // User did not enable Bluetooth or an error occured Log.d(TAG, "BT not enabled"); Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show(); finish(); } } }