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:org.gots.ui.TabSeedActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, final Intent data) { if (resultCode != Activity.RESULT_CANCELED) if (requestCode == PICK_IMAGE) { new AsyncTask<Void, Void, Void>() { @Override/*from w ww .j ava 2 s .c o m*/ protected Void doInBackground(Void... params) { GotsActionSeedManager.getInstance().initIfNew(getApplicationContext()).uploadPicture(mSeed, cameraPicture); // photoAction.execute(mSeed); return null; } protected void onPostExecute(Void result) { displayPictureGallery(); }; }.execute(); } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.gnucash.android.ui.common.BaseDrawerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_CANCELED) { super.onActivityResult(requestCode, resultCode, data); return;/*from ww w .j av a 2 s .c o m*/ } switch (requestCode) { case AccountsActivity.REQUEST_PICK_ACCOUNTS_FILE: AccountsActivity.importXmlFileFromIntent(this, data, null); break; case BaseDrawerActivity.REQUEST_OPEN_DOCUMENT: //this uses the Storage Access Framework final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); AccountsActivity.importXmlFileFromIntent(this, data, null); getContentResolver().takePersistableUriPermission(data.getData(), takeFlags); break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:ca.taglab.PictureFrame.ScreenSlidePageFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case CAPTURE_PICTURE: if (resultCode == Activity.RESULT_OK) { // Image captured and saved try { String photo_location = getLastImageId(); /**/*from w ww .j a v a2s .c o m*/ * Code for adding audio caption mAttachments = new String[2]; mAttachments[0] = photo_location; Intent intent = new Intent(getActivity(), AudioRecorderActivity.class); startActivityForResult(intent, CAPTURE_AUDIO_CAPTION); */ String[] attachments = { photo_location }; new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I have a photo for you", "", attachments).execute(); messageSent(mPhoto); } catch (Exception e) { // Photo to mEmail failed Log.e("SendEmailAsyncTask", e.getMessage(), e); } } else if (resultCode == Activity.RESULT_CANCELED) { // User cancelled photo capture } else { // Photo capture failed } break; case CAPTURE_VIDEO: if (resultCode == Activity.RESULT_OK) { // Video captured and saved try { String video_location = getLastVideoId(); String[] attachments = { video_location }; new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I have a video message for you", "", attachments).execute(); messageSent(mVideo); } catch (Exception e) { // Video to mEmail failed Log.e("SendEmailAsyncTask", e.getMessage(), e); } } else if (resultCode == Activity.RESULT_CANCELED) { // User cancelled video capture } else { // Video capture failed } break; case CAPTURE_AUDIO: if (resultCode == Activity.RESULT_OK) { // Audio captured and saved try { String audio_location = data.getStringExtra("audio_location"); String[] attachments = { audio_location }; new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I have an audio message for you", "", attachments).execute(); messageSent(mAudio); } catch (Exception e) { // Audio to mEmail failed Log.e("SendEmailAsyncTask", e.getMessage(), e); } } else if (resultCode == Activity.RESULT_CANCELED) { // User cancelled audio capture } else { // Audio capture failed } break; case CAPTURE_AUDIO_CAPTION: if (resultCode == Activity.RESULT_OK) { try { String audio_location = data.getStringExtra("audio_location"); mAttachments[1] = audio_location; new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I have a photo for you", "", mAttachments).execute(); messageSent(mPhoto); } catch (Exception e) { // Photo and audio caption to mEmail failed Log.e("SendEmailAsyncTask", e.getMessage(), e); } } else if (resultCode == Activity.RESULT_CANCELED) { // User cancelled audio capture } else { // Audio capture failed } break; default: Log.e(TAG, "Intent to start an activity failed"); break; } }
From source file:de.stadtrallye.rallyesoft.ConnectionAssistantActivity.java
@Override public void finish(boolean acceptNewConnection) { if (acceptNewConnection && server.hasUserAuth()) { Server.setCurrentServer(server); } else {//from w w w . j a va 2 s.c o m //server.destroy(); } setResult((acceptNewConnection) ? Activity.RESULT_OK : Activity.RESULT_CANCELED); super.finish(); }
From source file:com.wit.android.support.content.intent.ImageIntent.java
/** * Processes the given result <var>data</var> to obtain the requested Bitmap. * <p>/*from www.j a v a2 s . c o m*/ * <b>Note</b>, that in case of {@link #REQUEST_CODE_CAMERA}, the obtained Bitmap will be only todo.... * For full quality image pass an instance of Uri to {@link #output(android.net.Uri)}. * * @param requestCode The request code from {@link Activity#onActivityResult(int, int, android.content.Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, android.content.Intent)}. * Can be only one of {@link #REQUEST_CODE_CAMERA} or {@link #REQUEST_CODE_GALLERY}. * @param resultCode The result code from {@link Activity#onActivityResult(int, int, android.content.Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, android.content.Intent)}. * If {@link Activity#RESULT_OK}, the passed <var>data</var> will be processed, * otherwise {@code null} will be returned. * @param data The data from {@link Activity#onActivityResult(int, int, android.content.Intent)} or * {@link android.support.v4.app.Fragment#onActivityResult(int, int, android.content.Intent)}. * @param context Current valid context. * @param options Image options to adjust obtained bitmap. * @return Instance of Bitmap obtained from the given <var>data</var> Intent. */ @Nullable public static Bitmap processResultIntent(int requestCode, int resultCode, @Nullable Intent data, @NonNull Context context, @Nullable ImageOptions options) { if (data != null) { switch (resultCode) { case Activity.RESULT_OK: switch (requestCode) { case REQUEST_CODE_GALLERY: final Uri imageUri = data.getData(); Bitmap galleryImage = null; if (imageUri != null) { InputStream stream = null; try { stream = context.getContentResolver().openInputStream(imageUri); } catch (Exception e) { Log.e(TAG, "Unable to open image content: " + imageUri, e); } finally { if (stream != null) { if (options != null) { // Get the dimensions of the returned bitmap. final BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeStream(stream, null, bmOptions); final int bmWidth = bmOptions.outWidth; final int bmHeight = bmOptions.outHeight; // Compute how much to scale the bitmap. final int scaleFactor = Math.min(bmWidth / options.width, bmHeight / options.height); // Decode scaled bitmap. bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; galleryImage = BitmapFactory.decodeStream(stream, null, bmOptions); } else { galleryImage = BitmapFactory.decodeStream(stream); } try { stream.close(); } catch (IOException e) { Log.e(TAG, "Unable to close image content: " + imageUri, e); } } } } return galleryImage; case REQUEST_CODE_CAMERA: final Bundle extras = data.getExtras(); try { final Bitmap cameraImage = (extras != null) ? (Bitmap) extras.get("data") : null; if (cameraImage != null && options != null) { return Bitmap.createScaledBitmap(cameraImage, options.width, options.height, false); } return cameraImage; } catch (Exception e) { Log.e(TAG, "Failed to retrieve captured image.", e); } } break; case Activity.RESULT_CANCELED: // User canceled get image action. break; } } return null; }
From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java
private void doActivityResult() { // Intent data = new Intent(); Uri uri;/*from w w w. j a v a2 s . c om*/ Object[] objects; String name; // Bundle res; arrayListForResult = new ArrayList<String>(); rotateList = new ArrayList<Integer>(); try { if (checkedItems.size() == 0) { setResult(Activity.RESULT_CANCELED); AppManager.getAppManager().finishActivity(LocalAlbum.class); finish(); } else { int index = 0; for (LocalImageHelper.LocalFile localFile : checkedItems) { uri = Uri.parse(localFile.getOriginalUri()); objects = getImgInfo(uri); name = objects[0].toString(); Integer rotate = new Integer(objects[1].toString()); arrayListForResult.add(index++, name); rotateList.add(rotate); } // res = new Bundle(); // res.putStringArrayList("MULTIPLEFILENAMES", arrayList); // data.putExtras(res); // setResult(RESULT_OK, data); // app.setResultCode(Activity.RESULT_OK); // app.setFileNames(arrayListForResult); new ResizeImagesTask().execute(fileNames.entrySet()); } } catch (Exception ex) { // res = new Bundle(); // res.putString("ERRORMESSAGE", ex.getMessage()); // data.putExtras(res); // setResult(RESULT_CANCELED, data); app.setResultCode(Activity.RESULT_CANCELED); app.setErrMsg(ex.getMessage()); AppManager.getAppManager().finishActivity(LocalAlbum.class); finish(); } }
From source file:com.sdspikes.fireworks.FireworksActivity.java
@Override public void onActivityResult(int requestCode, int responseCode, Intent intent) { super.onActivityResult(requestCode, responseCode, intent); switch (requestCode) { case RC_SELECT_PLAYERS: // we got the result from the "select players" UI -- ready to create the room handleSelectPlayersResult(responseCode, intent); break;/* w ww. j a v a2s . c o m*/ case RC_INVITATION_INBOX: // we got the result from the "select invitation" UI (invitation inbox). We're // ready to accept the selected invitation: handleInvitationInboxResult(responseCode, intent); break; case RC_WAITING_ROOM: // we got the result from the "waiting room" UI. if (responseCode == Activity.RESULT_OK) { // ready to start playing Log.d(TAG, "Starting game (waiting room returned OK)."); startGame(true); } else if (responseCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) { // player indicated that they want to leave the room leaveRoom(); } else if (responseCode == Activity.RESULT_CANCELED) { // Dialog was cancelled (user pressed back key, for instance). In our game, // this means leaving the room too. In more elaborate games, this could mean // something else (like minimizing the waiting room UI). leaveRoom(); } break; case RC_SIGN_IN: Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode=" + responseCode + ", intent=" + intent); mSignInClicked = false; mResolvingConnectionFailure = false; if (responseCode == RESULT_OK) { mGoogleApiClient.connect(); } else { BaseGameUtils.showActivityResultError(this, requestCode, responseCode, R.string.signin_other_error); } break; } super.onActivityResult(requestCode, responseCode, intent); }
From source file:com.google.android.gms.samples.wallet.FullWalletConfirmationButtonFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { mProgressDialog.hide();/*w w w. ja v a 2 s . com*/ // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, -1); } switch (requestCode) { case REQUEST_CODE_RESOLVE_ERR: if (resultCode == Activity.RESULT_OK) { mGoogleApiClient.connect(); } else { handleUnrecoverableGoogleWalletError(errorCode); } break; case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case Activity.RESULT_OK: if (data.hasExtra(WalletConstants.EXTRA_FULL_WALLET)) { FullWallet fullWallet = data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); mActivityLaunchIntent.putExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet); startActivity(mActivityLaunchIntent); } break; case Activity.RESULT_CANCELED: // nothing to do here break; default: handleError(errorCode); break; } break; } }
From source file:org.opendatakit.survey.activities.MediaCaptureAudioActivity.java
private void returnResult() { File sourceMedia = (uriFragmentToMedia != null) ? ODKFileUtils.getRowpathFile(appName, tableId, instanceId, uriFragmentToMedia) : null;//from w w w . ja v a 2 s . co m if (sourceMedia != null && sourceMedia.exists()) { Intent i = new Intent(); i.putExtra(IntentConsts.INTENT_KEY_URI_FRAGMENT, ODKFileUtils.asRowpathUri(appName, tableId, instanceId, sourceMedia)); String name = sourceMedia.getName(); i.putExtra(IntentConsts.INTENT_KEY_CONTENT_TYPE, MEDIA_CLASS + name.substring(name.lastIndexOf(".") + 1)); setResult(Activity.RESULT_OK, i); finish(); } else { WebLogger.getLogger(appName).e(t, ERROR_NO_FILE + ((uriFragmentToMedia != null) ? sourceMedia.getAbsolutePath() : "null mediaPath")); Toast.makeText(this, R.string.media_save_failed, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } }
From source file:org.mifos.androidclient.templates.OperationFormActivity.java
public void onGoBackPressed(View view) { setResult(Activity.RESULT_CANCELED); finish(); }