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:cordova.plugin.RequestLocationAccuracy.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i(TAG, "onActivityResult()");
    switch (requestCode) {
    // Check for the integer request code originally supplied to startResolutionForResult().
    case REQUEST_CHECK_SETTINGS:
        switch (resultCode) {
        case Activity.RESULT_OK:
            String msg = "User agreed to make required location settings changes.";
            Log.i(TAG, msg);// w  w  w. j a  v a2s. c o m
            handleSuccess(msg, SUCCESS_USER_AGREED);
            break;
        case Activity.RESULT_CANCELED:
            handleError("User chose not to make required location settings changes.", ERROR_USER_DISAGREED);
            break;
        }
        break;
    }
}

From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java

private void sendFailure(WPayInitResponse wPayInitResponse) {
    Intent resultData = new Intent();
    resultData.putExtra(InAppUtil.EXTRA_KEY_RES_CODE, wPayInitResponse.getResCode());
    resultData.putExtra(InAppUtil.EXTRA_KEY_RES_DESC, "sdk init - " + wPayInitResponse.getResDesc());
    if (wPayInitResponse.getWibmoTxnId() != null) {
        resultData.putExtra(InAppUtil.EXTRA_KEY_WIBMO_TXN_ID, wPayInitResponse.getWibmoTxnId());
        if (wPayInitResponse.getTransactionInfo() != null) {
            resultData.putExtra(InAppUtil.EXTRA_KEY_MER_TXN_ID,
                    wPayInitResponse.getTransactionInfo().getMerTxnId());
            resultData.putExtra(InAppUtil.EXTRA_KEY_MER_APP_DATA,
                    wPayInitResponse.getTransactionInfo().getMerAppData());
        }//from  www  .j a  va2 s. c  om
    }

    setResult(Activity.RESULT_CANCELED, resultData);
    finish();
}

From source file:com.orbar.pxdemo.MainActivity.java

/**
 * receives the result of a successful login and starts the login actions
 */// w  w  w .j a  v  a  2  s  .  c o  m
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 1) {

        if (resultCode == Activity.RESULT_OK) {

            onSuccessLogin();

        }
        if (resultCode == Activity.RESULT_CANCELED) {
            Log.e(TAG, "Unable to login");
        }
    }
}

From source file:org.fdroid.fdroid.privileged.install.InstallExtensionDialogActivity.java

/**
 * 3. Verify that install worked//from   w  ww  .ja  v  a2  s .c om
 */
private void postInstall() {
    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");
    }

    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    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.amti.vela.bluetoothlegatt.bluetooth.DeviceScanActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    enableBtFlag = false;/* www. j a  va 2s .  c om*/
    // User chose not to enable Bluetooth.
    if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {

    } else if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_OK) {
        if (isBtCompat())
            autoConnectIfEnabled();
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.agustinprats.myhrv.MainActivity.java

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

    // User chose not to enable Bluetooth.
    if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
        Log.d(TAG, "User declined to enable BT: closing app");
        finish();/*from  w  w w  .  j a  v a 2 s.  co m*/
    } else if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_OK) {
        Log.d(TAG, "Bluetooth enabled");

        _heartRateService.reconnect();
    }

    super.onActivityResult(requestCode, resultCode, data);
}

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

public void showErrorAndClose(int resourceId, String logText) {
    ProvisionLogger.loge(logText);/*from   w w  w.  j ava 2s .c  om*/
    new AlertDialog.Builder(this).setTitle(R.string.provisioning_error_title).setMessage(getString(resourceId))
            .setCancelable(false)
            .setPositiveButton(R.string.device_owner_error_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    // Close activity
                    ProfileOwnerPreProvisioningActivity.this.setResult(Activity.RESULT_CANCELED);
                    ProfileOwnerPreProvisioningActivity.this.finish();
                }
            }).show();
}

From source file:com.github.vgoliveira.panificadora.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);

        }/*  www  . j  av a  2s  .  c  om*/
        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;
    case MainActivity.REQUEST_FACEBOOK_LOGIN:
        Toast.makeText(MainActivity.this, "Return Facebook Login", Toast.LENGTH_SHORT).show();
        String name = data.getStringExtra("name");
        String fbId = data.getStringExtra("id");
        String email = data.getStringExtra("email");
        String gender = data.getStringExtra("gender");
        String ageRange = data.getStringExtra("age_range");
        Toast.makeText(MainActivity.this, "User name: " + name, Toast.LENGTH_SHORT).show();
        Toast.makeText(MainActivity.this, "Facebook id: " + fbId, Toast.LENGTH_SHORT).show();
        Toast.makeText(MainActivity.this, "User email: " + email, Toast.LENGTH_SHORT).show();
        Toast.makeText(MainActivity.this, "Gender: " + gender, Toast.LENGTH_SHORT).show();
        Toast.makeText(MainActivity.this, "Age range: " + ageRange, Toast.LENGTH_SHORT).show();

        break;
    default:
        Log.e(TAG, "wrong request code");
        break;
    }
}

From source file:com.ntsync.android.sync.activities.ShopActivity.java

@Override
protected void onResumeFragments() {
    super.onResumeFragments();
    // Process a PaymentResult from onActivityResult
    if (paymentResult != null) {
        int resultCode = paymentResult.resultCode;
        PaymentConfirmation confirm = paymentResult.confirmation;
        paymentResult = null;/*from   w w w. j  a v  a 2s  .  com*/
        if (resultCode == Activity.RESULT_OK && confirm != null) {
            if (selectedPriceId == null) {
                MessageDialog.show(R.string.shop_activity_missingprice, this);
                return;
            }

            JSONObject paymentJson = confirm.toJSONObject();
            // Save Payment, so that payment can be verified later.
            Account account = new Account(accountName, Constants.ACCOUNT_TYPE);
            AccountManager accountManager = AccountManager.get(this);
            SyncUtils.savePayment(account, accountManager, paymentJson, selectedPriceId);

            SyncUtils.startPaymentVerification();
            // Start Timer to verify Payment if Verification could not be
            // done now.
            PaymentVerificationService.startVerificationTimer(getApplicationContext());

            // Send Confirmation to server
            boolean verifStarted = false;
            try {
                String jsonData = paymentJson.toString(1);
                VerifyPaymentProgressDialog progressDialog = VerifyPaymentProgressDialog
                        .newInstance(selectedPriceId, jsonData, accountName);
                progressDialog.show(this.getSupportFragmentManager(), "VerifyPaymentProgressDialog");
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "PaymentConfirmation: " + jsonData);
                }
                verifStarted = true;
            } catch (JSONException e) {
                MessageDialog.show(R.string.shop_activity_invalidsyntax, this);
                Log.e(TAG, "Failed to convert Payment to JSON.", e);
                SyncUtils.savePayment(account, accountManager, null, null);
            } finally {
                if (!verifStarted) {
                    SyncUtils.stopPaymentVerification();
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled the payment-flow");
        } else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
            MessageDialog.show(R.string.shop_activity_invalidpayment, this);
            Log.i(TAG, "An invalid payment was submitted.");
        } else {
            MessageDialog.show(R.string.shop_activity_invalidpayment, this);
            Log.e(TAG, "PaymentResult is unknown. Result:" + resultCode + " Confirmation:" + confirm);
        }
    }
    getSupportLoaderManager().initLoader(LOADID_PRICES, null, this);
    View progressBar = findViewById(R.id.progressBar);
    View reloadBtn = findViewById(R.id.reloadBtn);
    reloadBtn.setVisibility(View.GONE);
    progressBar.setVisibility(View.VISIBLE);
    getListView().setEmptyView(progressBar);

    // Show a Message from a delayed Verification
    String msg = getIntent().getStringExtra(PARM_MSG);
    if (msg != null) {
        MessageDialog.show(msg, this);
        getIntent().removeExtra(PARM_MSG);
    }
}

From source file:org.catrobat.catroid.ui.fragment.SoundFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    isAddNewSoundButtonClicked = false;/*w  w w.j  av a 2s. co m*/
    //when new sound title is selected and ready to be added to the catroid project
    if (resultCode == Activity.RESULT_OK && data != null) {
        switch (requestCode) {
        case SoundController.REQUEST_SELECT_MUSIC:
            Bundle arguments = new Bundle();
            arguments.putParcelable(SoundController.BUNDLE_ARGUMENTS_SELECTED_SOUND, data.getData());

            if (getLoaderManager().getLoader(SoundController.ID_LOADER_MEDIA_IMAGE) == null) {
                getLoaderManager().initLoader(SoundController.ID_LOADER_MEDIA_IMAGE, arguments, this);
            } else {
                getLoaderManager().restartLoader(SoundController.ID_LOADER_MEDIA_IMAGE, arguments, this);
            }
            break;
        case SoundController.REQUEST_MEDIA_LIBRARY:
            String filePath = data.getStringExtra(WebViewActivity.MEDIA_FILE_PATH);
            SoundController.getInstance().addSoundFromMediaLibrary(filePath, getActivity(), soundInfoList,
                    this);
        }
    }
    if (requestCode == SoundController.REQUEST_SELECT_MUSIC) {
        Log.d("SoundFragment", "onActivityResult RequestMusic");
        setHandleAddbutton();
    }

    if (resultCode == Activity.RESULT_CANCELED
            && ProjectManager.getInstance().getComingFromScriptFragmentToSoundFragment()) {

        getActivity().sendBroadcast(new Intent(ScriptActivity.ACTION_BRICK_LIST_CHANGED));
        ProjectManager.getInstance().setHandleCorrectAddButton(true);

        ImageButton addButton = (ImageButton) getSherlockActivity().findViewById(R.id.button_add);
        addButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                ScriptActivity scriptActivity = (ScriptActivity) getActivity();
                scriptActivity.getScriptFragment().handleAddButton();
            }
        });
        SoundController.getInstance().switchToScriptFragment(SoundFragment.this);
    }
    ProjectManager.getInstance().setComingFromScriptFragmentToSoundFragment(false);
}