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:freed.viewer.stack.StackActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stack_activity);
    Spinner stackvaluesButton = (Spinner) findViewById(R.id.freedviewer_stack_stackvalues_button);
    imageView = (TouchImageView) findViewById(R.id.freedviewer_stack_imageview);
    String[] items = new String[] { AVARAGE, AVARAGE1x2, AVARAGE1x3, AVARAGE3x3, LIGHTEN, LIGHTEN_V, MEDIAN,
            EXPOSURE };/*from  www . j  av a2 s . co  m*/
    ArrayAdapter<String> stackadapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item,
            items);
    stackvaluesButton.setAdapter(stackadapter);
    filesToStack = getIntent().getStringArrayExtra(DngConvertingFragment.EXTRA_FILESTOCONVERT);
    renderScriptHandler = new RenderScriptHandler(getContext());

    stackvaluesButton.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            stackMode = position;
        }

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

        }
    });

    Button buttonStartStack = (Button) findViewById(R.id.button_stackPics);
    buttonStartStack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            processStack();
        }
    });

    closeButton = (Button) findViewById(R.id.button_stack_close);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent returnIntent = new Intent();
            setResult(Activity.RESULT_CANCELED, returnIntent);
            finish();
        }
    });
    stackcounter = (TextView) findViewById(R.id.textView_stack_count);
    updateCounter(0);
}

From source file:de.kraenksoft.c3tv.ui.SearchFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_SPEECH:
        switch (resultCode) {
        case Activity.RESULT_OK:
            setSearchQuery(data, true);//w  w w  . ja v  a 2  s  .  c  om
            break;
        case Activity.RESULT_CANCELED:
            // Once recognizer canceled, user expects the current activity to process
            // the same BACK press as user doesn't know about overlay activity.
            // However, you may not want this behaviour as it makes harder to
            // fall back to keyboard input.
            if (FINISH_ON_RECOGNIZER_CANCELED) {
                if (!hasResults()) {
                    if (DEBUG)
                        Log.v(TAG, "Delegating BACK press from recognizer");
                    getActivity().onBackPressed();
                }
            }
            break;
        // the rest includes various recognizer errors, see {@link RecognizerIntent}
        }
        break;
    }
}

From source file:net.wespot.pim.utils.layout.NoticeDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    View view = inflater.inflate(R.layout.dialog_create_data_collection_task, null);

    builder.setView(view);/*from  w  ww  .j a v  a 2  s.c  om*/

    dialog_title = (EditText) view.findViewById(R.id.data_collection_dialog_title);
    dialog_description = (EditText) view.findViewById(R.id.data_collection_dialog_description);

    dialog_type_dc = (Spinner) view.findViewById(R.id.data_collection_dialog_type);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.data_collection_type, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(R.layout.spinner_layout);
    // Apply the adapter to the spinner
    dialog_type_dc.setAdapter(adapter);

    dialog_type_dc.setOnItemSelectedListener(this);

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setPositiveButton(R.string.data_collection_dialog_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            Intent a = getActivity().getIntent();
            a.putExtra(TITLE, dialog_title.getText());
            a.putExtra(DESCRIPTION, dialog_description.getText());

            setTitle(dialog_title.getText().toString());
            setDescription(dialog_description.getText().toString());
            setAudio(audio);
            setVideo(video);
            setImage(image);
            setText(text);
            setNumber(number);

            getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, a);
        }
    }).setNegativeButton(R.string.data_collection_dialog_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_CANCELED,
                    getActivity().getIntent());
        }
    });
    return builder.create();
}

From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        setResult(Activity.RESULT_CANCELED);
        finish();//from w  ww .  jav  a  2 s  .  c  om
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.andstatus.app.util.DialogFactory.java

public static Dialog newYesCancelDialog(final DialogFragment dialogFragment, String title, String message) {
    Dialog dlg;/*from   ww w. jav a  2  s.  c  o  m*/
    AlertDialog.Builder builder = new AlertDialog.Builder(dialogFragment.getActivity());
    builder.setTitle(title).setMessage(message).setPositiveButton(dialogFragment.getText(android.R.string.yes),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialogFragment.getTargetFragment().onActivityResult(dialogFragment.getTargetRequestCode(),
                            Activity.RESULT_OK, null);
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialogFragment.getTargetFragment().onActivityResult(dialogFragment.getTargetRequestCode(),
                            Activity.RESULT_CANCELED, null);
                }
            });
    dlg = builder.create();
    return dlg;
}

From source file:com.example.android.tvleanback2.ui.SearchFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (DEBUG) {/*  w w  w  .j a v a 2  s  .  com*/
        Log.v(TAG,
                "onActivityResult requestCode=" + requestCode + " resultCode=" + resultCode + " data=" + data);
    }
    switch (requestCode) {
    case REQUEST_SPEECH:
        switch (resultCode) {
        case Activity.RESULT_OK:
            setSearchQuery(data, true);
            break;
        case Activity.RESULT_CANCELED:
            // Once recognizer canceled, user expects the current activity to process
            // the same BACK press as user doesn't know about overlay activity.
            // However, you may not want this behaviour as it makes harder to
            // fall back to keyboard input.
            if (FINISH_ON_RECOGNIZER_CANCELED) {
                if (!hasResults()) {
                    if (DEBUG)
                        Log.v(TAG, "Delegating BACK press from recognizer");
                    getActivity().onBackPressed();
                }
            }
            break;
        // the rest includes various recognizer errors, see {@link RecognizerIntent}
        }
        break;
    }
}

From source file:com.molidt.easyandroid.bluetooth.BluetoothFragmentV4.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_ENABLE_BT) {
        if (resultCode == Activity.RESULT_OK) {
            if (mBluetoothStateListener != null)
                mBluetoothStateListener.enableBluetoothSuccess();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            if (mBluetoothStateListener != null)
                mBluetoothStateListener.enableBluetoothFail();
        }/*  w  ww  .jav  a 2 s  .  co m*/
    } else if (requestCode == REQUEST_DISCOVERABLE) {
        if (requestCode == Activity.RESULT_OK) {
            if (mDiscoverableModeListener != null)
                mDiscoverableModeListener.enableDiscoverableSuccess();
        } else if (requestCode == Activity.RESULT_CANCELED) {
            if (mDiscoverableModeListener != null)
                mDiscoverableModeListener.enableDiscoverableFial();
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.plugin.gallery.ForegroundGalleryLauncher.java

/**
 * Called when the camera view exits.//from   www  .j  a va 2 s.c  om
 * 
 * @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").
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (resultCode == Activity.RESULT_OK) {

        Uri uri = intent.getData();
        String fileURL = intent.getStringExtra("fileURL");
        System.out.println("fileURL = " + fileURL);
        ContentResolver resolver = this.cordova.getActivity().getContentResolver();

        try {
            Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            bitmap = scaleBitmap(bitmap);
            this.processPicture(bitmap);
            bitmap.recycle();
            bitmap = null;
            this.callbackContext.success("" + fileURL);
            System.gc();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            this.failPicture("Error retrieving image.");
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Selection cancelled.");
    } else {
        this.failPicture("Selection did not complete!");
    }
}

From source file:com.rei.lolchat.ui.Login.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == LOGIN_REQUEST_CODE) {
        mIsResult = true;//from w w w .j  a  v a 2 s  .  c  o m
        if (resultCode == Activity.RESULT_OK) {
            startActivity(new Intent(this, ContactList.class));
            finish();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            if (data != null) {
                String tmp = data.getExtras().getString("message");
                Toast.makeText(Login.this, tmp, Toast.LENGTH_SHORT).show();
                mTextView.setText(tmp);

                SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);
                String server = mSettings.getString(BeemApplication.LEVEL_KEY, "");

                tv_na = (TextView) findViewById(R.id.status_na);
                tv_eune = (TextView) findViewById(R.id.status_eune);
                tv_euw = (TextView) findViewById(R.id.status_euw);

                String text = "";

                text = "<font color='#0099FF'>[US]</font> Checking...";
                tv_na.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-NE]</font> Checking...";
                tv_eune.setText(Html.fromHtml(text));

                text = "<font color='#0099FF'>[EU-W]</font> Checking...";
                tv_euw.setText(Html.fromHtml(text));

                loadServerStatusTask task = new loadServerStatusTask();
                task.execute("na");

                loadServerStatusTask task2 = new loadServerStatusTask();
                task2.execute("eune");

                loadServerStatusTask task3 = new loadServerStatusTask();
                task3.execute("euw");

            }
        }
    }
}

From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent i) {
    if (requestCode == 0) {
        try {// w w w  . j a v  a  2  s.  c o m
            if (resultCode == Activity.RESULT_CANCELED)
                ;
            else {
                System.out.println(i.getStringExtra("data"));
                JSONObject m = new JSONObject(i.getStringExtra("data"));
                HashMap<String, String> s = new HashMap<>();
                s.put("machine_name", m.getString("machine_name"));
                s.put("machine_powertype", m.getString("machine_powertype"));
                s.put("machine_power", m.getString("machine_power"));
                s.put("passenger_num", m.getString("passenger_num"));
                s.put("machine_paytype", m.getString("machine_paytype"));
                s.put("machine_type", m.getString("machine_type"));
                s.put("machine_wheeldistance", m.getString("machine_wheeldistance"));
                s.put("machine_checktime", m.getString("machine_checktime"));
                s.put("machine_license1", m.getString("machine_license1"));
                s.put("machine_license2", m.getString("machine_license2"));
                s.put("drive_type", m.getString("drive_type"));
                if (m.getString("drive_type").equals("1")) {
                    s.put("driver_name", m.getString("driver_name"));
                    s.put("driver_age", m.getString("driver_age"));
                    s.put("driver_gender", m.getString("driver_gender"));
                    s.put("driver_license_type", m.getString("driver_license_type"));
                    s.put("driver_license", m.getString("driver_license"));
                }
                s.put("lease_month", m.getString("lease_month"));
                s.put("lease_time", m.getString("lease_time"));
                s.put("need_type", m.getString("need_type"));
                if (m.getString("need_type").equals("2")) {
                    s.put("need_item", m.getString("need_item"));
                }
                s.put("work_condition", m.getString("work_condition"));
                s.put("machine_house", m.getString("house_type"));
                data.add(s);
                adapter.setData(data);
                adapter.notifyDataSetChanged();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else if (requestCode == 1) {
        if (resultCode == Activity.RESULT_CANCELED) {
            System.out.println("canceled");
        } else if (resultCode == -1) {
            removeDataItem((HashMap<String, String>) i.getSerializableExtra("data"));
        } else {
            replaceDataItem((HashMap<String, String>) i.getSerializableExtra("data"));
            System.out.println(data.size());
        }
        adapter.setData(data);
        adapter.notifyDataSetChanged();
    }
}