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:org.cowboycoders.cyclisimo.CourseListActivity.java

private void cancel() {
    Intent resultData = new Intent();
    resultData.putExtra(getString(R.string.course_track_id), getTrackIdSharedPreference());
    setResult(Activity.RESULT_CANCELED, resultData);
    finish();/* w w  w . jav a 2  s  . c  o  m*/
}

From source file:org.creativecommons.thelist.misc.AddItemFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case PhotoConstants.PICK_PHOTO_REQUEST:
    case PhotoConstants.TAKE_PHOTO_REQUEST:
        if (resultCode == Activity.RESULT_OK) {
            if (data == null) {
                //Toast.makeText(this,getString(R.string.general_error),Toast.LENGTH_LONG).show();
                Log.d(TAG, "> onActivityResult > data == null");
            } else {
                mMediaUri = data.getData();
            }/*from   w ww  .  j av  a  2 s  . c  o  m*/
            Log.i(TAG, "Media URI:" + mMediaUri);

            //Add photo to the Gallery (listen for broadcast and let gallery take action)
            Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
            mediaScanIntent.setData(mMediaUri);
            getActivity().sendBroadcast(mediaScanIntent);

            Picasso.with(mContext).load(mMediaUri).into(mAddImage);
            mPhotoAdded = true;
        } //RESULT OK
        else if (resultCode != Activity.RESULT_CANCELED) { //result other than ok or cancelled
            //Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show();
            Log.d(TAG, "> onActivityResult > resultCode != canceled");
        }
        break;
    } //switch
}

From source file:de.eidottermihi.rpicheck.activity.EditRaspiActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == NewRaspiAuthActivity.REQUEST_LOAD) {
            final String filePath = data.getStringExtra(FileDialog.RESULT_PATH);
            LOGGER.debug("Path of selected keyfile: {}", filePath);
            deviceBean.setKeyfilePath(filePath);
            // set text to filename, not full path
            String fileName = NewRaspiAuthActivity.getFilenameFromPath(filePath);
            buttonKeyfile.setText(fileName);
        }/* w ww.j  ava 2  s  .c  o  m*/
    } else if (resultCode == Activity.RESULT_CANCELED) {
        LOGGER.warn("No file selected...");
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.camera.CameraOverlay.java

/**
 * ?????.//www . j a  va2  s  .c  om
 * @param resultReceiver ????
 */
private void checkCameraCapability(@NonNull final ResultReceiver resultReceiver) {
    PermissionUtility.requestPermissions(mContext, new Handler(), new String[] { Manifest.permission.CAMERA },
            new PermissionUtility.PermissionRequestCallback() {
                @Override
                public void onSuccess() {
                    resultReceiver.send(Activity.RESULT_OK, null);
                }

                @Override
                public void onFail(@NonNull String deniedPermission) {
                    resultReceiver.send(Activity.RESULT_CANCELED, null);
                }
            });
}

From source file:br.liveo.ndrawer.ui.activity.MainActivity.java

License:asdf

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEET_ENABLE_BT) {
        if (resultCode == Activity.RESULT_CANCELED) {
            finish();/*from   w  w  w. j a  v a2s .c o m*/
            return;
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.android.managedprovisioning.ProfileOwnerPreProvisioningActivity.java

private void showCurrentLauncherInvalid() {
    new AlertDialog.Builder(this).setCancelable(false)
            .setMessage(R.string.managed_provisioning_not_supported_by_launcher)
            .setNegativeButton(R.string.cancel_provisioning, new DialogInterface.OnClickListener() {
                @Override/*from w  w  w.j  a v  a  2 s. c  om*/
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    setResult(Activity.RESULT_CANCELED);
                    finish();
                }
            }).setPositiveButton(R.string.pick_launcher, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    pickLauncher();
                }
            }).show();
}

From source file:com.jtechme.apphub.privileged.install.InstallExtensionDialogActivity.java

/**
 * 3. Verify that install worked//from  w w  w  .  j  ava  2s. c o  m
 */
private void postInstall() {
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    int isInstalledCorrectly = PrivilegedInstaller.isExtensionInstalledCorrectly(this);

    String title;
    String message;
    final int result;
    switch (isInstalledCorrectly) {
    case PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES:
        title = getString(R.string.system_install_post_success);
        message = getString(R.string.system_install_post_success_message);
        result = Activity.RESULT_OK;

        // enable system installer on installation success
        Preferences.get().setPrivilegedInstallerEnabled(true);
        break;
    case PrivilegedInstaller.IS_EXTENSION_INSTALLED_NO:
        title = getString(R.string.system_install_post_fail);
        message = getString(R.string.system_install_post_fail_message);
        result = Activity.RESULT_CANCELED;
        break;
    case PrivilegedInstaller.IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM:
        title = getString(R.string.system_install_post_fail);
        message = getString(R.string.system_install_post_fail_message) + "\n\n"
                + getString(R.string.system_install_denied_signature);
        result = Activity.RESULT_CANCELED;
        break;
    case PrivilegedInstaller.IS_EXTENSION_INSTALLED_PERMISSIONS_PROBLEM:
        title = getString(R.string.system_install_post_fail);
        message = getString(R.string.system_install_post_fail_message) + "\n\n"
                + getString(R.string.system_install_denied_permissions);
        result = Activity.RESULT_CANCELED;
        break;
    default:
        throw new RuntimeException("unhandled return");
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(theme).setTitle(title).setMessage(message)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    InstallExtensionDialogActivity.this.setResult(result);
                    InstallExtensionDialogActivity.this.finish();
                    startActivity(new Intent(InstallExtensionDialogActivity.this, FDroid.class));
                }
            }).setCancelable(false);
    builder.create().show();
}

From source file:com.bluewatcher.activity.BlueWatcherActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SELECT_WATCH_REQUEST) {
        watchSelected(data);/*  w  w  w.j  ava  2s .c o m*/
        return;
    }

    if (requestCode == ENABLE_BLUETOOTH) {
        if (resultCode == Activity.RESULT_CANCELED) {
            finish();
            return;
        }
        initializeBlueWatcher();
        return;
    }

    applyConfiguration(false);
}

From source file:com.wordpress.bennthomsen.ble_uart_remote.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {

    case REQUEST_SELECT_DEVICE:
        //When the DeviceListActivity return, with the selected device address
        if (resultCode == Activity.RESULT_OK && data != null) {
            String deviceAddress = data.getStringExtra(BluetoothDevice.EXTRA_DEVICE);
            mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress);

            Log.d(TAG, "... onActivityResultdevice.address==" + mDevice + "mserviceValue" + mService);
            ((TextView) findViewById(R.id.deviceName)).setText(mDevice.getName() + " - connecting");
            mService.connect(deviceAddress);

        }//from w  ww.j  av  a 2s  .  com
        break;
    case REQUEST_ENABLE_BT:
        // When the request to enable Bluetooth returns
        if (resultCode == Activity.RESULT_OK) {
            Toast.makeText(this, "Bluetooth has turned on ", Toast.LENGTH_SHORT).show();

        } else {
            // User did not enable Bluetooth or an error occurred
            Log.d(TAG, "BT not enabled");
            Toast.makeText(this, "Problem in BT Turning ON ", Toast.LENGTH_SHORT).show();
            finish();
        }
        break;
    case MainActivity.REQUEST_SELECT_RECIPE:
        if (resultCode != Activity.RESULT_CANCELED) {
            value = null;
            bakery = (Bakery) data.getSerializableExtra("bakery");
            recipe = (Recipe) data.getSerializableExtra("recipe");

            value = bakery.setProgram(value);

            new AlertDialog.Builder(this).setTitle("Ateno").setMessage(
                    "Antes de continuar, cetifique-se que a bandeja foi inserida com todos os ingredientes.")
                    .setPositiveButton("Continuar", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            //send program to the machine
                            mService.writeRXCharacteristic(value);
                        }
                    }).show();

            //register this operation in cloud
        }
        break;
    default:
        Log.e(TAG, "wrong request code");
        break;
    }
}

From source file:org.chromium.chrome.browser.preferences.privacy.ConfirmImportantSitesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();/*from   w ww.  j a v a 2  s.co  m*/
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager = ((ActivityManager) ContextUtils.getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED,
                        getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater()
            .inflate(R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setTitle(R.string.storage_clear_site_storage_title)
            .setPositiveButton(R.string.clear_browsing_data_important_dialog_button, listener)
            .setNegativeButton(R.string.cancel, listener).setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}