List of usage examples for android.app Activity RESULT_CANCELED
int RESULT_CANCELED
To view the source code for android.app Activity RESULT_CANCELED.
Click Source Link
From source file:org.opendatakit.survey.activities.MediaChooseAudioActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); if (extras != null) { appName = extras.getString(IntentConsts.INTENT_KEY_APP_NAME); tableId = extras.getString(IntentConsts.INTENT_KEY_TABLE_ID); instanceId = extras.getString(IntentConsts.INTENT_KEY_INSTANCE_ID); uriFragmentNewFileBase = extras.getString(URI_FRAGMENT_NEW_FILE_BASE); }//from w w w. j ava 2 s .c om if (savedInstanceState != null) { appName = savedInstanceState.getString(IntentConsts.INTENT_KEY_APP_NAME); tableId = savedInstanceState.getString(IntentConsts.INTENT_KEY_TABLE_ID); instanceId = savedInstanceState.getString(IntentConsts.INTENT_KEY_INSTANCE_ID); uriFragmentNewFileBase = savedInstanceState.getString(URI_FRAGMENT_NEW_FILE_BASE); } if (appName == null) { throw new IllegalArgumentException( "Expected " + IntentConsts.INTENT_KEY_APP_NAME + " key in intent bundle. Not found."); } if (tableId == null) { throw new IllegalArgumentException( "Expected " + IntentConsts.INTENT_KEY_TABLE_ID + " key in intent bundle. Not found."); } if (instanceId == null) { throw new IllegalArgumentException( "Expected " + IntentConsts.INTENT_KEY_INSTANCE_ID + " key in intent bundle. Not found."); } if (uriFragmentNewFileBase == null) { throw new IllegalArgumentException( "Expected " + URI_FRAGMENT_NEW_FILE_BASE + " key in intent bundle. Not found."); } Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType(MEDIA_CLASS + "*"); try { startActivityForResult(i, ACTION_CODE); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.activity_not_found, Intent.ACTION_GET_CONTENT + " " + MEDIA_CLASS), Toast.LENGTH_SHORT).show(); setResult(Activity.RESULT_CANCELED); finish(); } }
From source file:org.openmidaas.app.activities.ScanFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == SCAN_REQUEST) { if (resultCode == Activity.RESULT_OK) { if (intent.getStringExtra("SCAN_RESULT") != null) { Logger.debug(getClass(), intent.getStringExtra("SCAN_RESULT")); ((MainTabActivity) getActivity()).processUrl(intent.getStringExtra("SCAN_RESULT")); } else { DialogUtils.showNeutralButtonDialog(getActivity(), "Error", "Error in scan"); }/*from ww w . j a va 2 s.co m*/ } else if (resultCode == Activity.RESULT_CANCELED) { Logger.debug(getClass(), "Scan cancelled"); } //Setting the tab back to precious tab ((MainTabActivity) getActivity()).mTabHost .setCurrentTabByTag(((MainTabActivity) getActivity()).currentTab); } }
From source file:com.appunite.helpers.EditFragment.java
protected void discardChanges() { mDiscard = true; FragmentActivity activity = getActivity(); activity.setResult(Activity.RESULT_CANCELED); activity.finish(); }
From source file:com.kaliturin.blacklist.fragments.AddContactsFragment.java
@Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // snack bar//from ww w . jav a 2 s .c om snackBar = new ButtonsBar(view, R.id.three_buttons_bar); // "Cancel button" button snackBar.setButton(R.id.button_left, getString(R.string.CANCEL), new View.OnClickListener() { @Override public void onClick(View v) { finishActivity(Activity.RESULT_CANCELED); } }); // "Add" button snackBar.setButton(R.id.button_center, getString(R.string.ADD), new View.OnClickListener() { @Override public void onClick(View v) { snackBar.dismiss(); // write checked contacts to the DB addCheckedContacts(); } }); // "Select all" button snackBar.setButton(R.id.button_right, getString(R.string.SELECT_ALL), new View.OnClickListener() { @Override public void onClick(View v) { setCheckedAllItems(); } }); // cursor adapter cursorAdapter = new ContactsCursorAdapter(getContext()); cursorAdapter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View row) { if (cursorAdapter.hasCheckedItems()) { snackBar.show(); } else { snackBar.dismiss(); } if (singleNumberMode && cursorAdapter.isItemChecked(row)) { Contact contact = cursorAdapter.getContact(row); if (contact != null && contact.numbers.size() > 1) { askForSingleContactNumber(contact); } } } }); // add cursor listener to the list ListView listView = (ListView) view.findViewById(R.id.contacts_list); listView.setAdapter(cursorAdapter); // on list empty comment TextView textEmptyView = (TextView) view.findViewById(R.id.text_empty); listView.setEmptyView(textEmptyView); // init and run the loader of contacts getLoaderManager().initLoader(0, null, newLoaderCallbacks(null)); }
From source file:com.facebook.login.LoginFragment.java
private void onLoginClientCompleted(LoginClient.Result outcome) { request = null;//w w w . j a v a 2 s. co m int resultCode = (outcome.code == LoginClient.Result.Code.CANCEL) ? Activity.RESULT_CANCELED : Activity.RESULT_OK; Bundle bundle = new Bundle(); bundle.putParcelable(RESULT_KEY, outcome); Intent resultIntent = new Intent(); resultIntent.putExtras(bundle); // The activity might be detached we will send a cancel result in onDetach if (isAdded()) { getActivity().setResult(resultCode, resultIntent); getActivity().finish(); } }
From source file:com.foregroundgalleryplugin.ForegroundGalleryLauncher.java
/** * Called when the camera view exits.//www .java2 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(); 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; 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.HumanDecisionSupportSystemsLaboratory.DD_P2P.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); {/* w w w.j a v a2 s . c om*/ // Use intent in case the app was started by another app to send messages/images Intent intent = getIntent(); if (intent != null) { Uri data = intent.getData(); if (intent.getType() != null) { // Figure out what to do based on the intent type if (intent.getType().contains("image/")) { // Handle intents with image data ... // should probably set here a window only to select contact destination // Create intent to deliver some kind of result data //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri")); // setResult(Activity.RESULT_OK, result); setResult(Activity.RESULT_CANCELED); finish(); } else if (intent.getType().equals("text/plain")) { // Handle intents with text ... // should probably set here a window only to select contact destination // Create intent to deliver some kind of result data //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri")); // setResult(Activity.RESULT_OK, result); setResult(Activity.RESULT_CANCELED); finish(); } } } } setContentView(R.layout.main); //initial action bar actionBar = this.getActionBar(); //set tab navigation mode actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //initial view pager mViewPager = (ViewPager) this.findViewById(R.id.pager); actionBar.setDisplayHomeAsUpEnabled(false); //add adapter mAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { // if (position > 1) position = 1; actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); //add tabs actionBar.addTab(actionBar.newTab().setText(Util.__("Connections")).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(Util.__("Organizations")).setTabListener(this)); if (PAGES_NB > 2) { actionBar.addTab(actionBar.newTab().setText("Acts").setTabListener(this)); } new net.ddp2p.common.util.DDP2P_ServiceThread("loading icons", false, this) { @Override public void _run() { Main m = (Main) ctx; Bitmap bmp = PhotoUtil.decodeSampledBitmapFromResource(getResources(), R.drawable.organization_default_img, 55, 55); icon_org = PhotoUtil.BitmapToByteArray(bmp, 100); } }.start(); }
From source file:net.wespot.pim.utils.layout.QuestionDialogFragment.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_question, null); builder.setView(view);//from w w w. ja v a2 s .c o m dialog_title = (EditText) view.findViewById(R.id.new_question_title_dialog); dialog_description = (EditText) view.findViewById(R.id.new_question_description_dialog); dialog_tags = (EditText) view.findViewById(R.id.new_question_tags_dialog); // dialog_title.setOnFocusChangeListener(new View.OnFocusChangeListener() { // @Override // public void onFocusChange(View view, boolean b) { // if (countWords(dialog_title.getText().toString()) < 5){ // Toast.makeText(getActivity(), "Question should be longer", Toast.LENGTH_SHORT).show(); // } // dialog_title.setFocusable(true); // dialog_title.setFocusableInTouchMode(true); // dialog_title.requestFocus(); // } // }); // 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.new_question_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()); a.putExtra(TAGS, (dialog_tags.getText().toString() != "" ? dialog_tags.getText() : "-")); setTitle(dialog_title.getText().toString()); setDescription(dialog_description.getText().toString()); setTags(dialog_tags.getText().toString()); getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, a); } }).setNegativeButton(R.string.new_question_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.gigigo.imagerecognition.vuforia.VuforiaActivity.java
@Override public void setContentViewTop(View vuforiaView) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.ir_activity_vuforia, null); scanLine = view.findViewById(R.id.scan_line); RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.layoutContentVuforiaGL); relativeLayout.addView(vuforiaView, 0); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) markFakeFeaturePoint = new MarkFakeFeaturePoint(this); relativeLayout.addView(markFakeFeaturePoint); ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); addContentView(view, vlp);/*from w w w . j av a 2 s.co m*/ //region Button Close view.findViewById(R.id.btnCloseVuforia).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(); i.putExtra(ImageRecognitionConstants.VUFORIA_PATTERN_ID, ""); setResult(Activity.RESULT_CANCELED, i); finish(); } }); //endregion mVuforiaView = vuforiaView; setThemeColorScheme(); startBoringAnimation(); scanlineStart(); }
From source file:com.aimfire.intro.IntroductionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_introduction); // ViewPager and its adapters use support library // fragments, so use getSupportFragmentManager. mIntroCollectionPagerAdapter = new IntroCollectionPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.intro_pager); mViewPager.setAdapter(mIntroCollectionPagerAdapter); mViewPager.setPageTransformer(true, new ZoomOutPageTransformer()); mNextBtn = (Button) findViewById(R.id.next_button); mSkipBtn = (Button) findViewById(R.id.skip_button); mNextBtn.setOnClickListener(new OnClickListener() { @Override// w w w . j a va 2 s. co m public void onClick(View v) { int pageNum = mViewPager.getCurrentItem(); if (pageNum == (NUM_PAGES - 1)) { //done updateIntroPrefs(); setResult(Activity.RESULT_OK, null); finish(); } else { mViewPager.setCurrentItem(pageNum + 1); } } }); mSkipBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //done updateIntroPrefs(); setResult(Activity.RESULT_CANCELED, null); finish(); } }); addDots(); selectDot(0); sPageTitles = Arrays.asList(getResources().getStringArray(R.array.introPageTitles)); sPageDesc = Arrays.asList(getResources().getStringArray(R.array.introPageDescs)); }