public static boolean checkNetworking(final FragmentActivity current) { if (!mNetwork.isConnected()) { Intent intent = new Intent(); intent.putExtra(WifiScannerFragment.CONNECTED, false); current.setResult(AppCompatActivity.RESULT_OK, intent); String title = current.getString(R.string.error); String message = current.getString(R.string.wifi_went_down); new FatalDialog(title, message, current).show(); return false; } return true; }
public void onBackPressed(){ mScanReceiver.unregister(); mConnectionReceiver.unregister(); Bundle bundle = new Bundle(); bundle.putBoolean(CONNECTED, mConnected); Intent intent = new Intent(); intent.putExtras(bundle); getActivity().setResult(AppCompatActivity.RESULT_OK, intent); getActivity().finish(); getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein); }
@Override public void onPostExecute(DeckTask.TaskData result) { if (result.getBoolean()) { getActivity().setResult(RESULT_OK); ((AnkiActivity) getActivity()).finishWithAnimation(ActivityTransitionAnimation.RIGHT); } else { // RuntimeException occurred getActivity().setResult(RESULT_CANCELED); ((AnkiActivity) getActivity()).finishWithoutAnimation(); } } };
@Override public void onItemClick(HighlightImpl highlightImpl) { Intent intent = new Intent(); intent.putExtra(HIGHLIGHT_ITEM, highlightImpl); intent.putExtra(Constants.TYPE, Constants.HIGHLIGHT_SELECTED); getActivity().setResult(Activity.RESULT_OK, intent); getActivity().finish(); }
@Override public void onTocClicked(int position) { TOCLinkWrapper tocLinkWrapper = (TOCLinkWrapper) mTOCAdapter.getItemAt(position); Intent intent = new Intent(); intent.putExtra(SELECTED_CHAPTER_POSITION, tocLinkWrapper.getTocLink().getHref()); intent.putExtra(BOOK_TITLE, tocLinkWrapper.getTocLink().getTitle()); intent.putExtra(TYPE, CHAPTER_SELECTED); getActivity().setResult(Activity.RESULT_OK, intent); getActivity().finish(); }
@Override public void onNewDraftCreated(String revision, String draftId) { if (mResult == null) { mResult = new Intent(); } mResult.putExtra(Constants.EXTRA_DATA_CHANGED, true); //noinspection ConstantConditions getActivity().setResult(Activity.RESULT_OK, mResult); }
@Override public void onDraftDeleted(String revision, String draftId) { if (mResult == null) { mResult = new Intent(); } mResult.putExtra(Constants.EXTRA_DATA_CHANGED, true); //noinspection ConstantConditions getActivity().setResult(Activity.RESULT_OK, mResult); }
/** * Set result for the parent activity to notify the requester about the action. * * @param resultCode The result code for the activity. * @param intent The result intent to provide any data as an extra. * @param finish {@code true} to finish the activity. */ protected void setResult(int resultCode, @Nullable Intent intent, boolean finish) { if (getActivity() != null) { if (intent != null) { getActivity().setResult(resultCode, intent); } else { getActivity().setResult(resultCode); } if (finish) { finishActivity(); } } }
@Override protected void onBottomFabClick() { super.onBottomFabClick(); HashMap<String, Object> arguments = new HashMap<>(); for (Items.Setting setting : mSettings) { if (setting.getUnit() == Items.Setting.Unit.ID) { arguments.put("id", setting.getName(getActivity()).toString()); arguments.put("uniqueId", setting.getUniqueId()); } else if (mEditTextViews.containsKey(setting)) { String text = mEditTextViews.get(setting).getText().toString(); if (!text.isEmpty()) { arguments.put(setting.getId(), text); } } else if (mCodeViews.containsKey(setting)) { arguments.put(setting.getId(), mCodeViews.get(setting).getCode().toString()); } } Intent intent = new Intent(); intent.putExtra(CustomControlsActivity.RESULT_INTENT, arguments); getActivity().setResult(0, intent); getActivity().finish(); }
@Override @SuppressWarnings("Convert2streamapi") public void onNext(Boolean result) { //noinspection ConstantConditions getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); showProgress(false); mPublishLoader.clear(); mLocked = false; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SHOW_FILES: toggleShowFiles(); folderPickerAdapter.setShowFiles(isShowFiles()); return true; case MENU_SHOW_HIDDEN: toggleShowHidden(); folderPickerAdapter.setShowHidden(isShowHidden()); return true; case MENU_ACCEPT: File current = folderPickerAdapter.getCurrentFolder(); if (!current.canWrite()) { Toast.makeText(getActivity(), R.string.folder_picker_cannot_write, Toast.LENGTH_SHORT).show(); return true; } Intent result = new Intent(null, Uri.fromFile(current)); getActivity().setResult(Activity.RESULT_OK, result); getActivity().finish(); return true; case MENU_GO_DEFAULT: folderPickerAdapter.setPath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)); return true; } return super.onOptionsItemSelected(item); }
getActivity().setResult(Activity.RESULT_OK, mResult);
private void performCancelEdit() { //noinspection ConstantConditions AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.change_edit_discard_title) .setMessage(R.string.change_edit_discard_message) .setPositiveButton(R.string.action_discard, (dialogInterface, i) -> { //noinspection ConstantConditions getActivity().setResult(Activity.RESULT_CANCELED); getActivity().finish(); }) .setNegativeButton(R.string.action_cancel, null) .create(); dialog.show(); }
Intent intent = new Intent(); intent.putExtra(RESULT_INTENT, file.toString()); getActivity().setResult(0, intent); getActivity().finish(); },