@Override public void onClick(DialogInterface dialog, int which) { setResult(RESULT_CANCELED); finish(); }
/** * Finishes the activity (with scan results if scan result listener is not set). */ private void finishWithResults() { Intent intent = new Intent(); setResult(RESULT_OK, intent); mRecognizerBundle.saveToIntent(intent); finish(); }
@Override public boolean onOptionsItemSelected(final MenuItem item) { int id = item.getItemId(); if (id == TORCH_ID) { mRecognizerView.setTorchState(!mTorchOn, new SuccessCallback() { @Override public void onOperationDone(boolean success) { if (success) { mTorchOn = !mTorchOn; runOnUiThread(new Runnable() { @Override public void run() { if (mTorchOn) { item.setIcon(R.drawable.mb_ic_flash_on_24dp); } else { item.setIcon(R.drawable.mb_ic_flash_off_24dp); } } }); } } }); return true; } else if (id == android.R.id.home) { setResult(RESULT_CANCELED); super.onBackPressed(); return true; } return super.onOptionsItemSelected(item); }