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.facebook.internal.FacebookDialogFragment.java
private void onCompleteWebDialog(Bundle values, FacebookException error) { FragmentActivity fragmentActivity = getActivity(); Intent resultIntent = NativeProtocol.createProtocolResultIntent(fragmentActivity.getIntent(), values, error);/*ww w. j a v a 2 s . co m*/ int resultCode = error == null ? Activity.RESULT_OK : Activity.RESULT_CANCELED; fragmentActivity.setResult(resultCode, resultIntent); fragmentActivity.finish(); }
From source file:org.opendatakit.survey.android.activities.MediaCaptureImageActivity.java
@Override protected void onResume() { super.onResume(); if (afterResult) { // this occurs if we re-orient the phone during the save-recording // action returnResult();//from ww w.j ava2s.c om } else if (!hasLaunched && !afterResult) { Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); // workaround for image capture bug // create an empty file and pass filename to Camera app. if (uriFragmentToMedia == null) { uriFragmentToMedia = uriFragmentNewFileBase + TMP_EXTENSION; } // to make the name unique... File mediaFile = ODKFileUtils.getAsFile(appName, uriFragmentToMedia); if (!mediaFile.exists()) { boolean success = false; String errorString = " Could not create: " + mediaFile.getAbsolutePath(); try { success = (mediaFile.getParentFile().exists() || mediaFile.getParentFile().mkdirs()) && mediaFile.createNewFile(); } catch (IOException e) { WebLogger.getLogger(appName).printStackTrace(e); errorString = e.toString(); } finally { if (!success) { String err = getString(R.string.media_save_failed); WebLogger.getLogger(appName).e(t, err + errorString); deleteMedia(); Toast.makeText(this, err, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); return; } } } i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(mediaFile)); try { hasLaunched = true; startActivityForResult(i, ACTION_CODE); } catch (ActivityNotFoundException e) { String err = getString(R.string.activity_not_found, android.provider.MediaStore.ACTION_IMAGE_CAPTURE); WebLogger.getLogger(appName).e(t, err); deleteMedia(); Toast.makeText(this, err, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } } }
From source file:org.ohmage.prompt.remoteactivity.RemoteActivityPrompt.java
/** * If the 'resultCode' indicates failure then we treat it as if the user * has skipped the prompt. If skipping is not allowed, we log it as an * error, but we do not make an entry in the results array to prevent * corrupting it nor do we set as skipped to prevent us from corrupting * the entire survey./* w w w .ja v a2 s.c o m*/ * * If the 'resultCode' indicates success then we check to see what was * returned via the parameterized 'data' object. If 'data' is null, we put * an empty JSONObject in the array to indicate that something went wrong. * If 'data' is not null, we get all the key-value pairs from the data's * extras and place them in a JSONObject. If the keys for these extras are * certain "special" return codes, some of which are required, then we * handle those as well which may or may not include putting them in the * JSONObject. Finally, we put the JSONObject in the JSONArray that is the * return value for this prompt type. */ @Override public void handleActivityResult(Context context, int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_CANCELED) { if (mSkippable.equalsIgnoreCase("true")) { this.setSkipped(true); } else if (mSkippable.equalsIgnoreCase("false")) { // The Activity was canceled for some reason, but it shouldn't // have been. Log.e(TAG, "The Activity was canceled, but the prompt isn't set as skippable."); } else { // This should _never_ happen! Log.e(TAG, "Invalid 'skippable' value: " + mSkippable); } } else if (resultCode == Activity.RESULT_OK) { if (data != null) { if (responseArray == null) { responseArray = new JSONArray(); } boolean singleValueFound = false; JSONObject currResponse = new JSONObject(); Bundle extras = data.getExtras(); Iterator<String> keysIter = extras.keySet().iterator(); while (keysIter.hasNext()) { String nextKey = keysIter.next(); if (FEEDBACK_STRING.equals(nextKey)) { feedbackText.setText(extras.getString(nextKey)); } else { try { currResponse.put(nextKey, extras.get(nextKey)); } catch (JSONException e) { Log.e(TAG, "Invalid return value from remote Activity for key: " + nextKey); } if (SINGLE_VALUE_STRING.equals(nextKey)) { singleValueFound = true; } } } if (singleValueFound) { responseArray.put(currResponse); } else { // We cannot add this to the list of responses because it // will be rejected for not containing the single-value // value. Log.e(TAG, "The remote Activity is not returning a single value which is required for CSV export."); } } else { // If the data is null, we put an empty JSONObject in the // array to indicate that the data was null. responseArray.put(new JSONObject()); Log.e(TAG, "The data returned by the remote Activity was null."); } } // TODO: Possibly support user-defined Activity results: // resultCode > Activity.RESULT_FIRST_USER // // One obvious possibility is some sort of "SKIPPED" return code. }
From source file:com.android.documentsui.DocumentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mRoots = DocumentsApplication.getRootsCache(this); setResult(Activity.RESULT_CANCELED); setContentView(R.layout.activity);/*from w w w . j a v a 2 s .co m*/ final Resources res = getResources(); mShowAsDialog = res.getBoolean(R.bool.show_as_dialog); if (mShowAsDialog) { // backgroundDimAmount from theme isn't applied; do it manually final WindowManager.LayoutParams a = getWindow().getAttributes(); a.dimAmount = 0.6f; getWindow().setAttributes(a); getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); getWindow().setFlags(~0, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Inset ourselves to look like a dialog final Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); final int width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x); final int height = (int) res.getFraction(R.dimen.dialog_height, size.y, size.y); final int insetX = (size.x - width) / 2; final int insetY = (size.y - height) / 2; final Drawable before = getWindow().getDecorView().getBackground(); final Drawable after = new InsetDrawable(before, insetX, insetY, insetX, insetY); getWindow().getDecorView().setBackground(after); // Dismiss when touch down in the dimmed inset area getWindow().getDecorView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { final float x = event.getX(); final float y = event.getY(); if (x < insetX || x > v.getWidth() - insetX || y < insetY || y > v.getHeight() - insetY) { finish(); return true; } } return false; } }); } else { // Non-dialog means we have a drawer mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_glyph, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerListener); mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START); mRootsContainer = findViewById(R.id.container_roots); } mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory); if (icicle != null) { mState = icicle.getParcelable(EXTRA_STATE); } else { buildDefaultState(); } // Hide roots when we're managing a specific root if (mState.action == ACTION_MANAGE) { if (mShowAsDialog) { findViewById(R.id.dialog_roots).setVisibility(View.GONE); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } } if (mState.action == ACTION_CREATE) { final String mimeType = getIntent().getType(); final String title = getIntent().getStringExtra(Intent.EXTRA_TITLE); SaveFragment.show(getFragmentManager(), mimeType, title); } if (mState.action == ACTION_GET_CONTENT) { final Intent moreApps = new Intent(getIntent()); moreApps.setComponent(null); moreApps.setPackage(null); RootsFragment.show(getFragmentManager(), moreApps); } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE) { RootsFragment.show(getFragmentManager(), null); } if (!mState.restored) { if (mState.action == ACTION_MANAGE) { final Uri rootUri = getIntent().getData(); new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor()); } else { new RestoreStackTask().execute(); } } else { onCurrentDirectoryChanged(ANIM_NONE); } }
From source file:org.mifos.androidclient.main.AccountDetailsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (resultCode) { case Activity.RESULT_OK: runAccountDetailsTask();//from ww w . ja v a2s.com break; case Activity.RESULT_CANCELED: break; default: break; } }
From source file:jp.alessandro.android.iab.PurchaseFlowLauncher.java
private Purchase getPurchase(int resultCode, int responseCode, String purchaseData, String signature) throws BillingException { // Check the Billing response if (resultCode == Activity.RESULT_OK && responseCode == Constants.BILLING_RESPONSE_RESULT_OK) { return getPurchaseFromIntent(purchaseData, signature); }/*from w w w. j a v a2s . c o m*/ // Something happened while trying to purchase the item switch (resultCode) { case Activity.RESULT_OK: throw new BillingException(responseCode, Constants.ERROR_MSG_RESULT_OK); case Activity.RESULT_CANCELED: throw new BillingException(responseCode, Constants.ERROR_MSG_RESULT_CANCELED); default: throw new BillingException(resultCode, String.format(Locale.US, Constants.ERROR_MSG_RESULT_UNKNOWN, resultCode)); } }
From source file:org.liberty.android.fantastischmemo.ui.CardEditor.java
@Override public void onBackPressed() { String qText = questionEdit.getText().toString(); String aText = answerEdit.getText().toString(); String nText = noteEdit.getText().toString(); if (!isEditNew && (!qText.equals(originalQuestion) || !aText.equals(originalAnswer) || !nText.equals(originalNote))) { new AlertDialog.Builder(this).setTitle(R.string.warning_text) .setMessage(R.string.edit_dialog_unsave_warning) .setPositiveButton(R.string.yes_text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int which) { SaveCardTask task = new SaveCardTask(); task.execute((Void) null); }// w ww .jav a2s . c om }).setNeutralButton(R.string.no_text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int which) { Intent resultIntent = new Intent(); setResult(Activity.RESULT_CANCELED, resultIntent); finish(); } }).setNegativeButton(R.string.cancel_text, null).create().show(); } else { Intent resultIntent = new Intent(); setResult(Activity.RESULT_CANCELED, resultIntent); finish(); } }
From source file:nl.mpcjanssen.simpletask.Simpletask.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_SHARE_PARTS: if (resultCode != Activity.RESULT_CANCELED) { int flags = resultCode - Activity.RESULT_FIRST_USER; shareTodoList(flags);/* w w w .j ava2 s.c om*/ } break; } }
From source file:com.vladstirbu.cordova.CDVInstagramVideoPlugin.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Log.v("InstagramVideo", "shared ok"); this.cbContext.success(); } else if (resultCode == Activity.RESULT_CANCELED) { Log.v("InstagramVideo", "share cancelled"); this.cbContext.error("Share Cancelled"); }//from ww w. jav a2s . c o m }
From source file:com.mbientlab.metawear.app.ModuleActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case START_MODULE_DETAIL: case DFU:/*w w w . j a v a 2s . c om*/ device = data.getParcelableExtra(EXTRA_BLE_DEVICE); if (device != null) { mwController = mwService.getMetaWearController(device); } break; case REQUEST_ENABLE_BT: if (resultCode == Activity.RESULT_CANCELED) { finish(); } break; } super.onActivityResult(requestCode, resultCode, data); }