Example usage for android.app Activity RESULT_OK

List of usage examples for android.app Activity RESULT_OK

Introduction

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

Prototype

int RESULT_OK

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

Click Source Link

Document

Standard activity result: operation succeeded.

Usage

From source file:de.da_sense.moses.client.LoginActivity.java

/**
 * Called if we got a SessionID from the server.
 * @param deviceName the name of the device returned from the server (may be null)
 *///w w  w  .j  a v  a  2 s . c om
private void valid(String deviceName) {
    Log.d("LoginActivity", "valid() called");
    loginDialog.dismiss();
    // get email and password
    String email = editTextEmail.getText().toString().trim();
    String password = editTextPassword.getText().toString();

    // set the result of the Activity and put the email and password
    Intent resultData = new Intent();
    resultData.putExtra(MosesPreferences.PREF_EMAIL, email);
    resultData.putExtra(MosesPreferences.PREF_PASSWORD, password);
    resultData.putExtra(MosesPreferences.PREF_DEVICENAME, deviceName);
    setResult(Activity.RESULT_OK, resultData);

    Log.d(LOG_TAG, "valid(): email = " + email + "\npassword = " + password);

    // persist the valid credentials if the box is set
    if (checkBoxRemember.isChecked())
        try {
            saveCredentials(email, password);
        } catch (IOException e) {
            Log.e(LOG_TAG, "valid(): there was a problem storing users credentials");
            e.printStackTrace();

        }
    else
        /* 
         * delete users credentials because the box was not checked. We also want to forget
         * previously stored credentials
         */
        deleteFile(FILENAME_CREDENTIALS);

    finish();

}

From source file:com.sck.maininterface.PaymentInfo.java

@SuppressWarnings("deprecation")
@Override/*w  ww .  j  a v a  2s  .  com*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 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));

                    /*   Toast.makeText(
                             getApplicationContext(),
                             "Payment Confirmation info received from PayPal",
                             Toast.LENGTH_LONG).show();*/

                    AlertDialog ad = new AlertDialog.Builder(this).create();
                    ad.setCancelable(false); // This blocks the 'BACK' button  
                    ad.setMessage("Payment Confirmation info received from PayPal");
                    ad.setButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    ad.show();
                    //new updateExpiryDate().execute();
                    //paymentSuccess=true;
                    saveExpDate(renewedDate);

                } 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.");
        }
    }

    // /

}

From source file:com.activiti.android.ui.fragments.form.picker.ActivitiUserPickerFragment.java

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

    switch (requestCode) {
    case RequestCode.PICK_CONTACT: {
        if (resultCode == Activity.RESULT_OK && data != null) {
            try {
                Uri contactUri = data.getData();

                // Cursor loader to query optional contact email
                CursorLoader clEmail = new CursorLoader(getActivity());
                clEmail.setProjection(new String[] { ContactsContract.CommonDataKinds.Email.ADDRESS });
                clEmail.setUri(contactUri);
                Cursor cursor = clEmail.loadInBackground();
                cursor.moveToFirst();/*  ww  w .java2 s .  c  o m*/

                // Retrieve the phone number from the NUMBER column
                int column = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
                String email = cursor.getString(column);
                searchForm.setText(email);
                ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true);
            } catch (Exception error) {
                Snackbar.make(getActivity().findViewById(R.id.left_panel), error.getMessage(),
                        Snackbar.LENGTH_LONG).show();
            }
        }
        break;
    }
    default:
        super.onActivityResult(requestCode, resultCode, data);
        break;
    }
}

From source file:com.groundupworks.wings.gcp.GoogleCloudPrintSettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gcp_activity_settings);

    mAuthenticationHelper = new OperatorGoogleAuthenticationActivityController(this, REQUEST_CODE_BASE + 100);
    mAccountSelectionHelper = new AccountSelectionActivityHelper(this, REQUEST_CODE_BASE);
    mGoogleCloudPrint = new GoogleCloudPrint();

    mSelectPrinterButton = (Button) findViewById(R.id.gcp_activity_settings_button_link);
    mPrinterSpinner = (Spinner) findViewById(R.id.gcp_activity_settings_spinner_printers);
    mPrinterSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override/*from   w  w w.j av a2s .  com*/
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            onPrinterSelected(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    mMediaSpinner = (Spinner) findViewById(R.id.gcp_activity_settings_spinner_media_sizes);

    mSelectPrinterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            final Printer selectedPrinter = (Printer) mPrinterSpinner.getSelectedItem();
            final MediaSize selectedMedia = (MediaSize) mMediaSpinner.getSelectedItem();
            if (selectedPrinter != null) {
                final String id = selectedPrinter.getId();
                final String account = mAccountSelected;
                final String token = mAuthenticationToken;
                if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(account) && !TextUtils.isEmpty(token)) {
                    final Intent intent = new Intent();
                    intent.putExtra(EXTRA_PRINTER, id);
                    intent.putExtra(EXTRA_PRINTER_NAME, selectedPrinter.getName());
                    intent.putExtra(EXTRA_ACCOUNT, account);
                    intent.putExtra(EXTRA_TOKEN, token);
                    if (selectedMedia != null) {
                        intent.putExtra(EXTRA_MEDIA, selectedMedia.id);
                    }

                    setResult(Activity.RESULT_OK, intent);
                    finish();
                }
            }
        }
    });
}

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;/* w ww  . 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);
        }
    }
}

From source file:com.phonegap.plugins.discoverscanar.DiscoverScanAR.java

/**
 * Called when the barcode scanner intent completes.
 *
 * @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").
 *///  ww w.  j  ava  2s.co  m
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // logging goes to logcat. LOG.d for debug(), LOG.e for error()
    // http://www.vogella.com/tutorials/AndroidLogging/article.html
    //Log.d(LOG_TAG, "#### onActivityResult");

    if (requestCode == REQUEST_SCAN_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, intent.getStringExtra("SCAN_RESULT"));
                obj.put(FORMAT, intent.getStringExtra("SCAN_RESULT_FORMAT"));
                obj.put(CANCELLED, false);
                this.callbackContext.success(obj);
                Log.e(LOG_TAG, "#### Found text: " + intent.getStringExtra("SCAN_RESULT")
                        + " AND Called callback on success");
            } catch (JSONException e) {
                Log.d(LOG_TAG, "This should never happen");
                this.callbackContext.error("Scan intent. Unexpected error: " + e.getMessage());
            }
            //this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
            //this.callbackContext.success(obj);
        } else if (resultCode == Activity.RESULT_CANCELED) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, "");
                obj.put(FORMAT, "");
                obj.put(CANCELLED, true);

                //Log.e(LOG_TAG, "#### Found no text");

                this.callbackContext.success(obj);
            } catch (JSONException e) {
                Log.d(LOG_TAG, "This should never happen");
                this.callbackContext.error("Scan intent. Unexpected error: " + e.getMessage());
            }
            //this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
            //this.callbackContext.success(obj);
        } else {
            //this.error(new PluginResult(PluginResult.Status.ERROR), this.callback);
            this.callbackContext.error("Scan intent. Unexpected error");
        }
    }

    else if (requestCode == REQUEST_ARSCAN_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, intent.getStringExtra("ARSCAN_RESULT"));
                obj.put(CANCELLED, false);
                this.callbackContext.success(obj);
            } catch (JSONException e) {
                Log.d(LOG_TAG, "ARScan intent (RESULT_OK) threw an exception: This should never happen");
                this.callbackContext.error("ARScan intent. Unexpected error: " + e.getMessage());
            }
            //this.callbackContext.success(obj);
        } else if (resultCode == Activity.RESULT_CANCELED) {
            JSONObject obj = new JSONObject();
            try {
                obj.put(TEXT, "");
                obj.put(CANCELLED, true);
                this.callbackContext.success(obj);
            } catch (JSONException e) {
                Log.d(LOG_TAG, "ARScan intent (RESULT_CANCELED) threw an exception. This should never happen");
                this.callbackContext.error("ARScan intent. Unexpected error: " + e.getMessage());
            }
            //this.callbackContext.success(obj);
        } else {
            //this.error(new PluginResult(PluginResult.Status.ERROR), this.callback);
            this.callbackContext.error("ARScan intent. Unexpected error");
        }
    }

}

From source file:org.ueu.uninet.it.IragarkiaBidali.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case PICK_IMAGE:
        if (resultCode == Activity.RESULT_OK) {
            Uri selectedImageUri = data.getData();

            try {
                // OI Fitxategi kudeatzailea
                String filemanagerstring = selectedImageUri.getPath();

                // MEDIA galeria
                String selectedImagePath = getPath(selectedImageUri);

                if (selectedImagePath != null) {
                    filePath = selectedImagePath;
                } else if (filemanagerstring != null) {
                    filePath = filemanagerstring;
                } else {
                    Toast.makeText(getApplicationContext(), "Kokapen ezezaguna", Toast.LENGTH_LONG).show();
                }/*w  w w. ja  va2  s. com*/

                if (filePath != null) {
                    Thread haria = new Thread() {
                        @Override
                        public void run() {
                            decodeFile(filePath);
                        }
                    };
                    haria.run();

                } else {
                    bitmap = null;
                }
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "Barne-errore bat egon da.", Toast.LENGTH_LONG).show();
            }
        }
        break;
    default:
    }
}

From source file:fr.cph.stock.android.activity.OverallActivity.java

@Override
public void reloadData(Portfolio portfolio) {
    shareValues.clear();//from w w w .java2  s. c  o  m
    shareValues.addAll(portfolio.getShareValues());
    ada.notifyDataSetChanged();
    refreshItem.collapseActionView();
    refreshItem.setActionView(null);
    Intent resultIntent = new Intent();
    resultIntent.putExtra("portfolio", portfolio);
    setResult(Activity.RESULT_OK, resultIntent);
    StockTrackerApp app = (StockTrackerApp) getApplication();
    app.toast();
}

From source file:com.gbaldera.tipaypal.TipaypalModule.java

@Override
public void onResult(Activity activity, int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);

        if (confirm != null) {
            try {

                // send 'confirm' to your server for verification.
                // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                // for more details.

                Log.i(TAG, confirm.toJSONObject().toString(4));
                processResult(resultCode, new KrollDict(confirm.toJSONObject()));

            } catch (JSONException e) {
                processFailed(resultCode, e);
            }/* ww  w. j av a 2  s. c  o m*/
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        processCanceled(resultCode);
    } else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
        processInvalid(resultCode);
    }
}