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.xbm.android.matisse.ui.MatisseActivity.java

@Override
public void onBackPressed() {
    setResult(Activity.RESULT_CANCELED);
    super.onBackPressed();
}

From source file:de.persoapp.android.core.adapter.MainViewFragment.java

public void startAuthentication(String tcTokenUrl, Intent extra) {
    if (mTcTokenUrl != null) {
        throw new IllegalStateException("You can only start one authentication per session.");
    }//from  w  ww  .  j  a  va 2s. c  o  m

    mTcTokenUrl = tcTokenUrl;
    mRefreshBrowser = extra == null || extra.getBooleanExtra(EXTRA_DO_REDIRECT, true);

    new Thread() {
        @Override
        public void run() {
            try {
                mRefreshAddress = ECardWorker.start(new URL(mTcTokenUrl));

                if (getActivity() != null) {
                    getActivity().setResult(Activity.RESULT_CANCELED,
                            new Intent().putExtra(EXTRA_REFRESH_ADDRESS, mRefreshAddress));
                }

            } catch (Exception e) {
                Cat.w(e, "Bad request");
                closeDialogs();
            }
        }
    }.start();
}

From source file:com.example.android.animationsdemo.PayPalActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    DKLog.d(TAG, Trace.getCurrentMethod()
            + String.format("requestCode: %s, resultCode: %s", requestCode, resultCode));
    if (requestCode == SwapubPayPal.REQUEST_CODE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    // 
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    // 
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));

                    PayPalResponse mPayPalResponse = new PayPalResponse();
                    mPayPalResponse.parseConfirmData(confirm.toJSONObject());
                    mPayPalResponse.parsePaymentData(confirm.getPayment().toJSONObject());
                    /**/*  ww  w  .j  a va2s.co  m*/
                     *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                     * or consent completion.
                     * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                     * for more details.
                     *
                     * For sample mobile backend interactions, see
                     * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                     */
                    Toast.makeText(getApplicationContext(), mPayPalResponse.toString(), Toast.LENGTH_LONG)
                            .show();

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:io.imoji.sdk.editor.fragment.ImojiEditorFragment.java

private void configureToolbar(View v) {
    //configure the toolbar
    mToolbar = (Toolbar) v.findViewById(R.id.imoji_toolbar);
    mToolbar.setNavigationIcon(R.drawable.create_back);
    mToolbar.inflateMenu(R.menu.menu_imoji_editor_fragment);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override//  w  w w. j a va2 s .c o  m
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.imoji_mi_editor_help) {
                if (isResumed()) {
                    TipsFragment f = TipsFragment.newInstance();
                    getFragmentManager().beginTransaction().addToBackStack(null)
                            .setCustomAnimations(R.anim.abc_fade_in, -1, -1, R.anim.imoji_fade_out)
                            .add(R.id.imoji_tag_container, f).commit();
                }
                return true;
            }
            return false;
        }
    });
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAdded()) {
                getActivity().setResult(Activity.RESULT_CANCELED);
                getActivity().finish();
            }
        }
    });

    mToolbarScrim = v.findViewById(R.id.imoji_toolbar_scrim);
    mBottomBarScrim = v.findViewById(R.id.imoji_bottom_bar_scrim);

    Drawable scrim = ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 32, Gravity.TOP);
    Drawable bottomBarScrim = ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 32, Gravity.BOTTOM);
    if (Build.VERSION.SDK_INT >= 16) {
        mToolbarScrim.setBackground(scrim);
        mBottomBarScrim.setBackground(bottomBarScrim);
    } else {
        mToolbarScrim.setBackgroundDrawable(scrim);
        mBottomBarScrim.setBackgroundDrawable(bottomBarScrim);
    }
}

From source file:de.schildbach.wallet.ui.ChannelRequestActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.channel_request_view);

    wallet = getWalletApplication().getWallet();

    acceptButton = (Button) findViewById(R.id.send_coins_go);
    acceptButton.setText(R.string.button_allow);
    acceptButton.setEnabled(false);//  ww w .j a va  2 s .c om
    acceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (validateAmounts(true)) {
                userSpecifiedMaxValue = currencyCalculatorLink.getAmount();
                if (service == null)
                    bindService(new Intent(ChannelRequestActivity.this, ChannelService.class), connection,
                            Context.BIND_AUTO_CREATE);
                else
                    allowAndFinish();
                disconnectAndFinish(Activity.RESULT_OK);
            }
        }
    });

    Button rejectButton = (Button) findViewById(R.id.send_coins_cancel);
    rejectButton.setText(R.string.button_reject);
    rejectButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismissPopup();
            disconnectAndFinish(Activity.RESULT_CANCELED);
        }
    });

    popupAvailableView = getLayoutInflater().inflate(R.layout.send_coins_popup_available, null);
    popupMessageView = (TextView) getLayoutInflater().inflate(R.layout.send_coins_popup_message, null);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    btcAmountView = (CurrencyAmountView) findViewById(R.id.channel_value_view_btc);
    btcAmountView.setCurrencySymbol(Constants.CURRENCY_CODE_BITCOIN);
    btcAmountView.setHintPrecision(Integer.parseInt(
            prefs.getString(Constants.PREFS_KEY_BTC_PRECISION, Constants.PREFS_DEFAULT_BTC_PRECISION)));

    CurrencyAmountView localAmountView = (CurrencyAmountView) findViewById(R.id.channel_value_view_local);
    localAmountView.setHintPrecision(Constants.LOCAL_PRECISION);

    currencyCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView);
    currencyCalculatorLink.setListener(amountsListener);
    currencyCalculatorLink.setEnabled(true);

    loaderManager = getSupportLoaderManager();

    handleIntent(getIntent());
}

From source file:com.laevatein.internal.ui.PhotoSelectionActivity.java

@Override
public void onBackPressed() {
    if (mCollection.isEmpty()) {
        setResult(Activity.RESULT_CANCELED);
        super.onBackPressed();
        return;//from  www  . ja va2s. c o m
    }
    ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.l_confirm_dialog_title,
            R.string.l_confirm_dialog_message);
    dialog.show(getSupportFragmentManager(), ConfirmationDialogFragment.TAG);
}

From source file:org.klnusbaum.udj.PlayerListFragment.java

public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    switch (requestCode) {
    case ACCOUNT_CREATION_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            account = (Account) data.getParcelableExtra(Constants.ACCOUNT_EXTRA);
        } else {/*from w  ww  .j a v  a 2  s .  c  om*/
            getActivity().setResult(Activity.RESULT_CANCELED);
            getActivity().finish();
        }
        break;
    default:
        super.onActivityResult(requestCode, resultCode, data);
    }

}

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

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

    if (resultCode == Activity.RESULT_CANCELED) {
        return;//from   w  ww  .ja va2s .c o  m
    }

    /* Refresh the activity according to activities */
    switch (requestCode) {
    case ACTIVITY_EDIT: {
        Bundle extras = data.getExtras();
        int cardId = extras.getInt(CardEditor.EXTRA_RESULT_CARD_ID, 1);
        Card card = getDbOpenHelper().getCardDao().queryForId(cardId);
        if (card != null) {
            setCurrentCard(card);
        }
        restartActivity();
        break;
    }

    case ACTIVITY_CARD_PLAYER: {
        Bundle extras = data.getExtras();
        int cardId = extras.getInt(CardPlayerActivity.EXTRA_RESULT_CARD_ID, 1);
        Card card = getDbOpenHelper().getCardDao().queryForId(cardId);
        if (card != null) {
            setCurrentCard(card);
        }
        restartActivity();
        break;
    }

    case ACTIVITY_SETTINGS: {
        restartActivity();
        break;
    }
    case ACTIVITY_LIST: {
        restartActivity();
        break;
    }
    case ACTIVITY_MERGE: {
        restartActivity();
        break;
    }
    case ACTIVITY_DETAIL: {
        restartActivity();
    }

    }
}

From source file:com.ichi2.anki.multimediacard.fields.BasicImageFieldController.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_CANCELED) {
        // Do Nothing.
    } else if (requestCode == ACTIVITY_SELECT_IMAGE) {
        Uri selectedImage = data.getData();
        // Timber.d(selectedImage.toString());
        String[] filePathColumn = { MediaColumns.DATA };

        Cursor cursor = mActivity.getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();/*  w ww . j a  v a  2  s . c o  m*/

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        cursor.close();

        mField.setImagePath(filePath);
    } else if (requestCode == ACTIVITY_TAKE_PICTURE) {
        String imagePath = rotateAndCompress(mTempCameraImagePath);
        mField.setImagePath(imagePath);
        mField.setHasTemporaryMedia(true);
    }
    setPreviewImage(mField.getImagePath(), getMaxImageSize());
}

From source file:net.wespot.pim.view.InqQuestionFragment.java

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

        if (resultCode == Activity.RESULT_OK) {
            // After Ok code.
            Log.i(TAG, "ok code");

            InquiryQuestionLocalObject questionLocalObject = new InquiryQuestionLocalObject();
            questionLocalObject/*from  ww  w . jav  a  2s.com*/
                    .setDescription(data.getExtras().get(QuestionDialogFragment.DESCRIPTION).toString());
            questionLocalObject.setTitle(data.getExtras().get(QuestionDialogFragment.TITLE).toString());
            questionLocalObject.setInquiryId(INQ.inquiry.getCurrentInquiry().getId());
            questionLocalObject.setInquiryLocalObject(INQ.inquiry.getCurrentInquiry());
            questionLocalObject
                    .setTags(data.getExtras().get(QuestionDialogFragment.TAGS).toString().equals("") ? "-"
                            : data.getExtras().get(QuestionDialogFragment.TAGS).toString());

            CreateQuestionObject createQuestionObject = new CreateQuestionObject();
            createQuestionObject.question = questionLocalObject;

            ARL.eventBus.register(this);
            ARL.eventBus.post(createQuestionObject);

            Toast.makeText(getActivity(), getResources().getString(R.string.question_sync), Toast.LENGTH_SHORT)
                    .show();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            // After Cancel code.
            Log.i(TAG, "cancel code");
        }
        break;
    }
}