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.davidmiguel.gobees.monitoring.MonitoringFragment.java
@Nullable @Override//from w ww . j av a2 s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.monitoring_frag, container, false); // Configure OpenCV callback loaderCallback = new BaseLoaderCallback(getContext()) { @Override public void onManagerConnected(final int status) { if (status == LoaderCallbackInterface.SUCCESS) { presenter.onOpenCvConnected(); } else { super.onManagerConnected(status); } } }; // Don't switch off screen getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // Configure camera cameraView = (CameraView) root.findViewById(R.id.camera_view); cameraView.setCameraIndex(CameraBridgeViewBase.CAMERA_ID_BACK); cameraView.setMaxFrameSize(MAX_WIDTH, MAX_HEIGHT); // Configure view numBeesTV = (TextView) root.findViewById(R.id.num_bees); settingsLayout = (RelativeLayout) getActivity().findViewById(R.id.settings); chronometer = (Chronometer) root.findViewById(R.id.chronometer); // Configure icons settingsIcon = (ImageView) root.findViewById(R.id.settings_icon); settingsIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { presenter.openSettings(); } }); recordIcon = (ImageView) root.findViewById(R.id.record_icon); recordIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { presenter.startMonitoring(); } }); // Configure service connection mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder service) { MonitoringBinder binder = (MonitoringBinder) service; mService = binder.getService(new GoBeesDataSource.SaveRecordingCallback() { @Override public void onRecordingTooShort() { // Finish activity with error Intent intent = new Intent(); intent.putExtra(HiveRecordingsFragment.ARGUMENT_MONITORING_ERROR, HiveRecordingsFragment.ERROR_RECORDING_TOO_SHORT); getActivity().setResult(Activity.RESULT_CANCELED, intent); getActivity().finish(); } @Override public void onSuccess() { // Finish activity with OK getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); } @Override public void onFailure() { // Finish activity with error Intent intent = new Intent(); intent.putExtra(HiveRecordingsFragment.ARGUMENT_MONITORING_ERROR, HiveRecordingsFragment.ERROR_SAVING_RECORDING); getActivity().setResult(Activity.RESULT_CANCELED, intent); getActivity().finish(); } }); // Set chronometer chronometer.setBase(mService.getStartTime()); chronometer.setVisibility(View.VISIBLE); chronometer.start(); } @Override public void onServiceDisconnected(ComponentName componentName) { mService = null; } }; return root; }
From source file:io.imoji.sdk.editor.fragment.CreateTaskFragment.java
private void notifyFailure(Activity a) { EditorBitmapCache.getInstance().clearNonOutlinedBitmaps(); a.setResult(Activity.RESULT_CANCELED, null); a.finish(); }
From source file:com.adobe.phonegap.csdk.ImageEditor.java
/** * Called when the image editor exits.//from w ww . j a va 2 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) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case 1: Uri editedImageUri = intent.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI); this.callbackContext.success(editedImageUri.toString()); break; } } else if (resultCode == Activity.RESULT_CANCELED) { this.callbackContext.error("Editor Canceled"); } }
From source file:com.univpm.s1055802.faceplusplustester.Detect.AcquireVideo.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { //super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_TAKE_VIDEO) { if (resultCode == RESULT_CANCELED) { FileUtils.deleteRecursive(videoDir); setResult(Activity.RESULT_CANCELED); } else {//from w ww . j av a 2s . com captureFrames(Uri.fromFile(videoFile)); //captureFrames(data.getData()); startActivityForResult(galleryIntent, GALLERY_INTENT_CALLED); } finish(); } }
From source file:com.oe.phonegap.plugins.AutoRecordVideo.java
/** * Called when the video view exits./* w ww. j a v a 2 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"). * @throws JSONException */ public void onActivityResult(int requestCode, int resultCode, final Intent intent) { // Result received okay if (resultCode == Activity.RESULT_OK) { // An audio clip was requested if (requestCode == CAPTURE_VIDEO) { final AutoRecordVideo that = this; Runnable captureVideo = new Runnable() { @Override public void run() { Uri data = null; if (intent != null) { // Get the uri of the video clip data = intent.getData(); } if (data == null) { File movie = new File(getTempDirectoryPath(), "AutoRecordVideo.avi"); OELog.d("data null " + movie.toURI()); data = Uri.fromFile(movie); } // create a file object from the uri if (data == null) { that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null")); } else { result = createMediaFile(data); OELog.d("Camera success" + data); that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } } }; this.cordova.getThreadPool().execute(captureVideo); } } // If canceled else if (resultCode == Activity.RESULT_CANCELED) { // If we have partial results send them back to the user if (result != null) { this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } // user canceled the action else { this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled.")); } } // If something else else { // If we have partial results send them back to the user if (result != null) { this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } // something bad happened else { this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!")); } } }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mRoots = DocumentsApplication.getRootsCache(this); virtualIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); virtualIntent.addCategory(Intent.CATEGORY_OPENABLE); virtualIntent.setType("*/*"); virtualIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); setResult(Activity.RESULT_CANCELED); setContentView(R.layout.activity);// w w w .jav a 2 s . c om 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 { if (DEBUG) { Log.i(TAG, "mState"); } 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 = virtualIntent.getType(); final String title = virtualIntent.getStringExtra(Intent.EXTRA_TITLE); SaveFragment.show(getFragmentManager(), mimeType, title); } if (mState.action == ACTION_GET_CONTENT) { final Intent moreApps = new Intent(virtualIntent); 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 = virtualIntent.getData(); new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor()); } else { new RestoreStackTask().execute(); } } else { onCurrentDirectoryChanged(ANIM_NONE); } }
From source file:codepath.watsiapp.activities.BaseFragmentActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { showThankYouNote();//from w w w. j a v a2 s. c om ParseObject confirmation = new ParseObject("PaymentConfirmatons"); confirmation.put("donorName", getUserFullName()); confirmation.put("donorEmail", getUserEmail()); confirmation.put("patient", Patient.createWithoutData(Patient.class, getPatientId())); confirmation.put("amount", getDonationAmount()); confirmation.put("confirmation", confirm.toJSONObject().toString(4)); confirmation.put("isAnonymous", isAnonymousDonation()); confirmation.saveInBackground(); prefs.clear(); } catch (JSONException e) { Log.e(TAG_PAYPAL, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG_PAYPAL, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i(TAG_PAYPAL, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } }
From source file:org.opendatakit.survey.activities.MediaCaptureAudioActivity.java
@Override protected void onResume() { super.onResume(); if (afterResult) { // this occurs if we re-orient the phone during the save-recording // action returnResult();//from w w w . java 2s.c om } else if (!hasLaunched && !afterResult) { Intent i = new Intent(Audio.Media.RECORD_SOUND_ACTION); // to make the name unique... File f = ODKFileUtils.getRowpathFile(appName, tableId, instanceId, (uriFragmentToMedia == null ? uriFragmentNewFileBase : uriFragmentToMedia)); int idx = f.getName().lastIndexOf('.'); if (idx == -1) { i.putExtra(Audio.Media.DISPLAY_NAME, f.getName()); } else { i.putExtra(Audio.Media.DISPLAY_NAME, f.getName().substring(0, idx)); } try { hasLaunched = true; startActivityForResult(i, ACTION_CODE); } catch (ActivityNotFoundException e) { String err = getString(R.string.activity_not_found, Audio.Media.RECORD_SOUND_ACTION); WebLogger.getLogger(appName).e(t, err); Toast.makeText(this, err, Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } } }
From source file:fragments.NewTicket.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case COLOR_PICKER: if (resultCode == Activity.RESULT_OK) { Bundle bundle = data.getExtras(); String color = bundle.getString("color", ""); ticketColor.setText(color);//from ww w . j a va 2 s . co m } else if (resultCode == Activity.RESULT_CANCELED) { ticketColor.setText(""); } break; } }
From source file:com.phonegap.customcamera.NativeCameraLauncher.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { // If image available if (resultCode == Activity.RESULT_OK) { resultIntent = intent;//from w w w . j a v a 2 s . c om this.cordova.getThreadPool().execute(this); } // If cancelled else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Camera cancelled."); } // back button clicked else if (resultCode == CAMERA_CANCELD) { this.cancelPicture(); } // If something else else { this.failPicture("Did not complete!"); } }