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.schedjoules.eventdiscovery.framework.locationpicker.LocationPickerFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home && getActivity() != null) {
        getActivity().setResult(Activity.RESULT_CANCELED);
        getActivity().finish();//from w  w w.ja  v a  2 s  . co  m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.android.contacts.SimImportFragment.java

@Nullable
@Override//w  ww . j  a v a2  s  . com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_sim_import, container, false);

    mAccountHeaderContainer = view.findViewById(R.id.account_header_container);
    mAccountScrolledElevationPixels = getResources().getDimension(R.dimen.contact_list_header_elevation);
    mAccountHeaderPresenter = new AccountHeaderPresenter(mAccountHeaderContainer);
    if (savedInstanceState != null) {
        mAccountHeaderPresenter.onRestoreInstanceState(savedInstanceState);
    } else {
        // Default may be null in which case the first account in the list will be selected
        // after they are loaded.
        mAccountHeaderPresenter.setCurrentAccount(mPreferences.getDefaultAccount());
    }
    mAccountHeaderPresenter.setObserver(new AccountHeaderPresenter.Observer() {
        @Override
        public void onChange(AccountHeaderPresenter sender) {
            rememberSelectionsForCurrentAccount();
            mAdapter.setAccount(sender.getCurrentAccount());
            showSelectionsForCurrentAccount();
            updateToolbarWithCurrentSelections();
        }
    });
    mAdapter.setAccount(mAccountHeaderPresenter.getCurrentAccount());

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnScrollListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
    mListView.setOnItemClickListener(this);
    mImportButton = view.findViewById(R.id.import_button);
    mImportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            importCurrentSelections();
            // Do we wait for import to finish?
            getActivity().setResult(Activity.RESULT_OK);
            getActivity().finish();
        }
    });

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().setResult(Activity.RESULT_CANCELED);
            getActivity().finish();
        }
    });

    mLoadingIndicator = (ContentLoadingProgressBar) view.findViewById(R.id.loading_progress);

    return view;
}

From source file:com.vantiv.android.gms.samples.wallet.FullWalletConfirmationButtonFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    mProgressDialog.hide();// w  w  w  .  j  a  va  2s . co m

    // 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_LOAD_FULL_WALLET:
        switch (resultCode) {
        case Activity.RESULT_OK:
            if (data != null && 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 != null && 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:com.money.manager.ex.assetallocation.SecurityListFragment.java

@Override
protected void setResult() {
    Intent result;//from   ww  w. ja  v  a2 s  .c  o m
    switch (this.action) {
    case Intent.ACTION_PICK:
        result = new Intent();
        result.putExtra(INTENT_RESULT_STOCK_SYMBOL, selectedStockSymbol);
        if (TextUtils.isEmpty(selectedStockSymbol)) {
            getActivity().setResult(Activity.RESULT_CANCELED, result);
        } else {
            getActivity().setResult(Activity.RESULT_OK, result);
        }
        break;

    default:
        // otherwise return cancel
        getActivity().setResult(Activity.RESULT_CANCELED);
        break;
    }
}

From source file:org.alfresco.mobile.android.application.activity.PrivateDialogActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PassCodeActivity.REQUEST_CODE_PASSCODE && resultCode == RESULT_CANCELED) {
        setResult(Activity.RESULT_CANCELED);
        finish();/*  www  .ja  va  2  s .c  o  m*/
    }
}

From source file:org.opendatakit.survey.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();// w ww .  j  a  va  2s  .  co m
    } else if (!hasLaunched && !afterResult) {
        Intent i = null;
        if (launchIntent == null) {
            i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        } else {
            i = launchIntent;
        }
        // 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.getRowpathFile(appName, tableId, instanceId, 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 intentActivityName = null;
            if (launchIntent != null && launchIntent.getComponent() != null) {
                intentActivityName = launchIntent.getComponent().getClassName();
            }
            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.gnucash.android.ui.transaction.SplitEditorFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case android.R.id.home:
        getActivity().setResult(Activity.RESULT_CANCELED);
        getActivity().finish();/*from  ww w. j a  v a  2 s  .c o m*/
        return true;

    case R.id.menu_save:
        saveSplits();
        return true;

    case R.id.menu_add_split:
        addSplitView(null);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.DistanceDialogFragment.java

/** Prepares the result.
 * @param sendResult <code>true</code> to send result, <code>false</code> to cancel.
 */// www .j  a  v a2 s  . c om
private void prepareResults(boolean sendResult) {
    if (sendResult) {
        Intent data = new Intent();
        data.putExtra(KEY_DISTANCE, currentDistanceValue);
        getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, data);
    } else {
        getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED, null);
    }
}

From source file:org.liberty.android.fantastischmemo.ui.CardListActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Refresh activity when the data has been changed.
    if (resultCode == Activity.RESULT_CANCELED) {
        return;//w w  w .  ja va2 s  .  c  o  m
    } else {
        restartActivity();
    }
}

From source file:com.evothings.BLE.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    Runnable onPowerOn = mOnPowerOn;
    CallbackContext cc = mPowerOnCallbackContext;
    mOnPowerOn = null;/*from ww w.  j  a v  a 2  s .c o  m*/
    mPowerOnCallbackContext = null;
    if (resultCode == Activity.RESULT_OK) {
        onPowerOn.run();
    } else {
        if (resultCode == Activity.RESULT_CANCELED) {
            cc.error("Bluetooth power-on canceled");
        } else {
            cc.error("Bluetooth power-on failed, code " + resultCode);
        }
    }
}