Example usage for android.app Activity RESULT_CANCELED

List of usage examples for android.app Activity RESULT_CANCELED

Introduction

In this page you can find the example usage for android.app Activity RESULT_CANCELED.

Prototype

int RESULT_CANCELED

To view the source code for android.app Activity RESULT_CANCELED.

Click Source Link

Document

Standard activity result: operation canceled.

Usage

From source file:com.by_syk.lib.nanoiconpack.dialog.IconDialog.java

private void returnPickIcon() {
    Bitmap bitmap = null;/*from  ww  w.ja v a2s .  co m*/
    try {
        bitmap = BitmapFactory.decodeResource(getResources(), iconBean.getId());
    } catch (Exception e) {
        e.printStackTrace();
    }

    Intent intent = new Intent();
    if (bitmap != null) {
        intent.putExtra("icon", bitmap);
        intent.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", iconBean.getId());
        intent.setData(Uri.parse("android.resource://" + getContext().getPackageName() + "/"
                + String.valueOf(iconBean.getId())));
        getActivity().setResult(Activity.RESULT_OK, intent);
    } else {
        getActivity().setResult(Activity.RESULT_CANCELED, intent);
    }
    getActivity().finish();
}

From source file:com.wearme.fat.ui.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
        finish();/*from w ww.  j  a v  a 2 s  .c  om*/
        return;
    } else if (requestCode == 54) {
        initUserDataList();
        initViewPager();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:de.j4velin.pedometer.ui.Activity_Main.java

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (requestCode == RC_RESOLVE) {
        // We're coming back from an activity that was launched to resolve a
        // connection problem. For example, the sign-in UI.
        if (resultCode == Activity.RESULT_OK && !mGoogleApiClient.isConnected()
                && !mGoogleApiClient.isConnecting()) {
            // Ready to try to connect again.
            mGoogleApiClient.connect();/*from w ww.j  av  a 2  s. c  om*/
        } else if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED
                && !mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) {
            mGoogleApiClient.connect();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            // User cancelled.
            mGoogleApiClient.disconnect();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:org.gnucash.android.ui.account.AccountsListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_CANCELED)
        return;/*from  www.  j a v a  2  s  .  c o  m*/

    refresh();
}

From source file:com.sourceallies.android.zonebeacon.activity.TransferActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_RESOLVE_ERROR) {
        // User was presented with the Nearby opt-in dialog and pressed "Allow".
        resolvingError = false;/*from   w  w  w . j a v a2s.  c o m*/

        if (resultCode == Activity.RESULT_OK) {
            if (shareData) {
                publish(client, message);
            } else {
                subscribe(client, messageListener);
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            finish();
        } else {
            Toast.makeText(this, "Failed to resolve error with code " + resultCode, Toast.LENGTH_LONG).show();
        }
    }
}

From source file:com.plugin.camera.ForegroundCameraLauncher.java

/**
 * Called when the camera view exits./*from   w ww  .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").
 */
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 {
                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;
                }
            }
            //This if block is added to the plugin to solve the issue which was saving portrait images in landscape with -90 degree rotetion
            if (intent.getBooleanExtra("portrait", false)) {
                Matrix matrix = new Matrix();
                matrix.preRotate(90);
                try {
                    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
                            true);
                } catch (Exception e) {
                    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth() / 2, bitmap.getHeight() / 2,
                            matrix, true);
                    e.printStackTrace();
                }
            }

            // 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.meetingninja.csse.notes.NotesFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1) { // EditNoteActivity
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                int listPosition = data.getIntExtra("listPosition", -1);
                Note editedNote = (Note) data.getParcelableExtra(Keys.Note.PARCEL);

                int _id = Integer.valueOf(editedNote.getID());

                // if (listPosition != -1)
                // updateNote(listPosition, editedNote);
                // else
                // updateNote(_id, editedNote);

                populateList();//from  w  w w. j  a  va2 s  .c  o  m
            }
        } else {
            if (resultCode == Activity.RESULT_CANCELED) {
                // nothing to do here
            }
        } // end EditNoteActivity
    } else if (requestCode == 3) { // CreateNoteActivity
        if (resultCode == Activity.RESULT_OK) {
            Toast.makeText(getActivity(), "New Note Created", Toast.LENGTH_SHORT).show();
            populateList();
        }
    } // end CreateNoteActivity
}

From source file:github.daneren2005.dsub.activity.EditPlayActionActivity.java

private void cancel() {
    setResult(Activity.RESULT_CANCELED);
    finish();
}

From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java

/**
 * Called when the file picker view exits.
 *
 * @param requestCode/*from   w ww . jav  a2s. c o m*/
 *        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 && intent != null) {
        final Intent i = intent;
        cordova.getThreadPool().execute(new Runnable() {
            public void run() {
                processResult(i);
            }
        });
    } else if (resultCode == Activity.RESULT_CANCELED) {
        this.failFile("Selection cancelled.");
    } else {
        this.failFile("Selection did not complete!");
    }
}

From source file:com.thenextplateau.ubristlebotcontroller.DeviceScanActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // User did not enable Bluetooth
    if (requestCode == REQUEST_ENABLE_BLUETOOTH && resultCode == Activity.RESULT_CANCELED) {
        finish();//w w w  .  j a  v a  2s .c om
        return;
    } else {
        // Start scanning for devices
        startDeviceScan(true);
    }
    super.onActivityResult(requestCode, resultCode, data);
}