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.pindroid.activity.FragmentBaseActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_CANCELED && requestCode != Constants.REQUEST_CODE_ACCOUNT_CHANGE) {
        finish();/* w  w w .  j  a va 2 s  . co  m*/
    } else if (resultCode == Activity.RESULT_OK && requestCode == Constants.REQUEST_CODE_ACCOUNT_CHANGE) {
        setAccount(data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME));
    } else if (resultCode == Activity.RESULT_OK && requestCode == Constants.REQUEST_CODE_ACCOUNT_INIT) {
        setAccount(AccountHelper.getFirstAccount(this).name);
    }
}

From source file:com.mifos.mifosxdroid.dialogfragments.DocumentDialogFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case FILE_SELECT_CODE:
        if (resultCode == Activity.RESULT_OK) {
            // Get the Uri of the selected file
            Uri uri = data.getData();/* w w  w .  ja  v  a 2  s  .  com*/

            Log.d(LOG_TAG, "File Uri: " + uri.toString());
            // Get the path
            try {

                String scheme = uri.getScheme();

                if (scheme.equals("file")) {
                    filePath = FileUtils.getPath(getActivity(), uri);
                    fileChoosen = new File(filePath);
                    Log.d(LOG_TAG, "File Path: " + filePath);
                } else if (scheme.equals("content")) {

                    Toast.makeText(getActivity(),
                            "The application currently does not "
                                    + "support file picking from apps other than File " + "Managers.",
                            Toast.LENGTH_SHORT).show();
                    resultCode = Activity.RESULT_CANCELED;
                }

                if (fileChoosen != null) {
                    tv_choose_file.setText(fileChoosen.getName());
                } else {
                    break;
                }
                bt_upload.setEnabled(true);

            } catch (URISyntaxException e) {
                Log.d(LOG_TAG, e.getMessage());
            }
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.univpm.s1055802.faceplusplustester.Detect.AcquirePhoto.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    //super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_TAKE_PHOTO) {
        if (resultCode == RESULT_CANCELED) {
            photoFile.delete();//w ww . ja v  a  2  s .c  om
            setResult(Activity.RESULT_CANCELED);
        } else {
            Intent detectIntent = new Intent(this, DetectImage.class);
            detectIntent.putExtra(AQUIRED_PHOTO, photoFile.getAbsolutePath());
            startActivityForResult(detectIntent, REQUEST_DETECT_PHOTO);
        }
        finish();
    } else if (requestCode == REQUEST_DETECT_PHOTO) {
        finish();
    }
}

From source file:it.personal.keyring.SetupActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.setup_action_cancel:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        ///* w w w.j ava  2s  . co  m*/
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        // NavUtils.navigateUpFromSameTask(this);
        setResult(Activity.RESULT_CANCELED);
        finish();
        return true;
    case R.id.setup_action_save:
        if (!save()) {
            return false;
        }
        setResult(Activity.RESULT_OK);
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:cn.tycoon.lighttrans.fileManager.AbstractFilePickerActivity.java

@Override
public void onCancelled() {
    setResult(Activity.RESULT_CANCELED);
    finish();
}

From source file:com.cloudstudio.BarcodeScanner.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").
 *//*from  ww  w .j a v  a  2  s . c om*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == REQUEST_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);
            } catch (JSONException e) {
                Log.d(LOG_TAG, "This should never happen");
            }
            //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);
            } catch (JSONException e) {
                Log.d(LOG_TAG, "This should never happen");
            }
            //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("Unexpected error");
        }
    }
}

From source file:com.example.android.bluetoothlegatt.DeviceScanActivity.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) {
        finish();//  w w  w  .ja v a2 s  . co  m
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.jaspersoft.android.jaspermobile.activities.inputcontrols.MultiSelectActivity.java

@Override
public void onBackPressed() {
    Intent dataIntent = new Intent();
    dataIntent.putExtra(SELECT_IC_ARG, inputControlId);

    int resultCode = isValueChanged ? Activity.RESULT_OK : Activity.RESULT_CANCELED;
    setResult(resultCode, dataIntent);/*from  w  w w  .j av a2s  . co m*/

    super.onBackPressed();
}

From source file:com.mgalgs.trackthatthing.LocationReceiver.java

public void updateResultsInUi() {
    SharedPreferences settings = mContext.getSharedPreferences(TrackThatThing.PREFS_NAME,
            android.content.Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();

    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss a yyyy-MM-dd");
    Calendar cal = Calendar.getInstance();

    editor.putString(TrackThatThing.PREF_LAST_LOC_TIME, sdf.format(cal.getTime()));
    editor.commit();/*  w  w w .  j  av a2 s .c om*/

    Intent i = new Intent(TheTracker.IF_LOC_UPDATE);
    // i.putExtra(TimerDB.KEY_ID, id);
    Log.d(TrackThatThing.TAG, "Pinging TheTracker...");
    mContext.sendOrderedBroadcast(i, null, new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int result = getResultCode();
            if (result != Activity.RESULT_CANCELED) {
                Log.d(TrackThatThing.TAG, "TheTracker caught the broadcast, result " + result);
                return; // Activity caught it
            }
            Log.d(TrackThatThing.TAG, "TimerActivity did not catch the broadcast");
        }
    }, null, Activity.RESULT_CANCELED, null, null);
}

From source file:com.barion.example.app2app.libraryintegration.fragments.ShopFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Barion.REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            BarionGetPaymentStateResponse response = (BarionGetPaymentStateResponse) data
                    .getSerializableExtra(Barion.BARION_PAYMENT_STATE_RESPONSE);
            if (response != null && getActivity() != null) {
                Intent intent = new Intent(getActivity(), PaymentResultActivity.class);
                intent.putExtra(Globals.KEY_PAYMENTSTATE, response);
                startActivity(intent);//from   w  w  w.  j a  v a  2  s. c om
                getActivity().finish();
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            if (data.hasExtra(Barion.ERROR)) {
                ArrayList<BarionError> errors = (ArrayList<BarionError>) data
                        .getSerializableExtra(Barion.ERROR);
                processBarionErrors(errors);
            } else if (data.hasExtra(Barion.BARION_PAYMENT_STATE_RESPONSE)) {
                BarionGetPaymentStateResponse response = (BarionGetPaymentStateResponse) data
                        .getSerializableExtra(Barion.BARION_PAYMENT_STATE_RESPONSE);
                if (response != null) {
                    Log.d(TAG, "Response: " + response.getPaymentState().getStatus());
                }
            }
        }
    }
}