Java Code Examples for android.app.AlertDialog#setCancelable()
The following examples show how to use
android.app.AlertDialog#setCancelable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraBridgeViewBase.java From SoftwarePilot with MIT License | 6 votes |
private void onEnterStartedState() { /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 2
Source File: CameraBridgeViewBase.java From OpenCV-AndroidSamples with MIT License | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 3
Source File: CameraBridgeViewBase.java From marvel with MIT License | 6 votes |
private void onEnterStartedState() { /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 4
Source File: CameraBridgeViewBase.java From OpenCvFaceDetect with Apache License 2.0 | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 5
Source File: CameraBridgeViewBase.java From MOAAP with MIT License | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 6
Source File: CameraBridgeViewBase.java From MOAAP with MIT License | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 7
Source File: CameraBridgeViewBase.java From OpenCV-Android-Object-Detection with MIT License | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 8
Source File: PermissionHelper.java From justaline-android with Apache License 2.0 | 6 votes |
/** * Show dialog with rationale for required permissions * * @param activity calling activity which the AlertDialog is shown on (PermissionsActivity) * @return the dialog that is shown */ private static AlertDialog showRequiredPermissionRationale(final Activity activity) { final AlertDialog alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle(activity.getString(R.string.title_activity_permissions)); alertDialog.setMessage(activity.getString(R.string.initial_permissions_required)); alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL, activity.getString(R.string.ask_me_again), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); requestRequiredPermissions(activity, true); } }); alertDialog.setCancelable(false); alertDialog.show(); return alertDialog; }
Example 9
Source File: CameraBridgeViewBase.java From effective_android_sample with Apache License 2.0 | 6 votes |
private void onEnterStartedState() { /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 10
Source File: CameraBridgeViewBase.java From android-object-distance with Apache License 2.0 | 6 votes |
private void onEnterStartedState() { /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 11
Source File: CameraBridgeViewBase.java From FaceT with Mozilla Public License 2.0 | 6 votes |
private void onEnterStartedState() { Log.d(TAG, "call onEnterStartedState"); /* Connect camera */ if (!connectCamera(getWidth(), getHeight())) { AlertDialog ad = new AlertDialog.Builder(getContext()).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed."); ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ((Activity) getContext()).finish(); } }); ad.show(); } }
Example 12
Source File: LatinIME.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
private void showSubtypeSelectorAndSettings() { final CharSequence title = getString(R.string.english_ime_input_options); // TODO: Should use new string "Select active input modes". final CharSequence languageSelectionTitle = getString(R.string.language_selection_title); final CharSequence[] items = new CharSequence[] { languageSelectionTitle, getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)) }; final String imeId = mRichImm.getInputMethodIdOfThisIme(); final OnClickListener listener = new OnClickListener() { @Override public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { case 0: final Intent intent = IntentUtils.getInputLanguageSelectionIntent( imeId, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle); startActivity(intent); break; case 1: launchSettings(); break; } } }; final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(this)); builder.setItems(items, listener).setTitle(title); final AlertDialog dialog = builder.create(); dialog.setCancelable(true /* cancelable */); dialog.setCanceledOnTouchOutside(true /* cancelable */); showOptionDialog(dialog); }
Example 13
Source File: SettingActivity.java From RelaxFinger with GNU General Public License v2.0 | 5 votes |
public void showUpdateInfo() { AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("悬浮助手-3.0.4.3版本更新内容"); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setMessage("" + "1.全新的切换上一应用模式,速度更快,不再需要“使用情况访问权限”。\r\n"+ "2.修复屏幕旋转权限问题。\r\n"+ "3.优化快捷菜单半透明背景,覆盖状态栏和导航栏。\r\n"+ "4.修复选择切换上一应用手势不能立即生效的问题。"+ ""); dialog.show(); }
Example 14
Source File: PdfActivity.java From Reader with Apache License 2.0 | 5 votes |
@Override public void showOpenErrorDialog(String reason) { Resources res = getResources(); mAlertBuilder = new AlertDialog.Builder(this); AlertDialog alert = mAlertBuilder.create(); alert.setCancelable(false); alert.setTitle(String.format(res.getString(R.string.cannot_open_document_Reason), reason)); alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); alert.show(); }
Example 15
Source File: QuestionWidget.java From commcare-android with Apache License 2.0 | 5 votes |
/** * Display extra help, triggered by user request. */ private void fireHelpText(final Runnable r) { if (!mPrompt.hasHelp()) { return; } // Depending on ODK setting, help may be displayed either as // a dialog or inline, underneath the question text if (showHelpWithDialog()) { AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create(); ScrollView scrollView = new ScrollView(this.getContext()); scrollView.addView(createHelpLayout()); mAlertDialog.setView(scrollView); DialogInterface.OnClickListener errorListener = (dialog, i) -> { switch (i) { case DialogInterface.BUTTON1: dialog.cancel(); if (r != null) r.run(); break; } }; mAlertDialog.setCancelable(true); mAlertDialog.setButton(StringUtils.getStringSpannableRobust(this.getContext(), R.string.ok), errorListener); mAlertDialog.show(); } else { if (helpPlaceholder.getVisibility() == View.GONE) { expand(helpPlaceholder); } else { collapse(helpPlaceholder); } } }
Example 16
Source File: PromotionsFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public void showPromotionOverDialog() { loading.setVisibility(View.GONE); LayoutInflater inflater = LayoutInflater.from(getContext()); View dialogLayout = inflater.inflate(R.layout.promotions_promotion_over_dialog, null); AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(dialogLayout) .create(); dialog.setCancelable(false); dialogLayout.findViewById(R.id.dismiss_button) .setOnClickListener(view -> { promotionOverDialogClick.onNext(null); dialog.dismiss(); }); dialog.show(); }
Example 17
Source File: ImportDatabaseActivity.java From xDrip with GNU General Public License v3.0 | 5 votes |
private void importDB(File the_file, Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Importing, please wait"); builder.setMessage("Importing, please wait"); AlertDialog dialog = builder.create(); dialog.show(); dialog.setMessage("Step 1: checking prerequisites"); dialog.setCancelable(false); LoadTask lt = new LoadTask(dialog, the_file); lt.execute(); }
Example 18
Source File: DialogFragments.java From ScreenShift with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); final AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setMessage(R.string.keep_settings_question) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ((DialogListener) getActivity()).onNegativeButton(KeepSettingsDialog.this); } }) .setPositiveButton(R.string.yes, null) .setCancelable(false) .create(); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); final Handler handler = new Handler(); final Runnable revertRunnable = new Runnable(){ @Override public void run() { if(dialog.isShowing()) { try { dialog.dismiss(); } catch (Exception e) { e.printStackTrace(); } ((DialogListener) getActivity()).onNegativeButton(KeepSettingsDialog.this); } } }; handler.postDelayed(revertRunnable, 1000*13); return dialog; }
Example 19
Source File: MainActivity.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
@NeedsPermission({Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}) void startExportAsyncTask() { String runningTaskClassName = MyApplication.getBackgroundTaskName(); if (runningTaskClassName != null) { Timber.d("startExportAsyncTask(): Another task is running in background: %s", runningTaskClassName); backgroundTaskHelper.showTaskRunningMessage(runningTaskClassName); return; } if (StorageUtils.isExternalMemoryWritable()) { final PreferencesProvider preferencesProvider = MyApplication.getPreferencesProvider(); List<FileType> recentFileTypes = preferencesProvider.getEnabledExportFileTypes(); LayoutInflater inflater = LayoutInflater.from(this); View dialogLayout = inflater.inflate(R.layout.configure_exporter_dialog, null); final CheckBox csvExportCheckbox = dialogLayout.findViewById(R.id.csv_export_dialog_checkbox); csvExportCheckbox.setChecked(recentFileTypes.contains(FileType.Csv)); final CheckBox gpxExportCheckbox = dialogLayout.findViewById(R.id.gpx_export_dialog_checkbox); gpxExportCheckbox.setChecked(recentFileTypes.contains(FileType.Gpx)); final CheckBox csvOcidExportCheckbox = dialogLayout.findViewById(R.id.csv_ocid_export_dialog_checkbox); csvOcidExportCheckbox.setChecked(recentFileTypes.contains(FileType.CsvOcid)); final CheckBox jsonMlsExportCheckbox = dialogLayout.findViewById(R.id.json_mls_export_dialog_checkbox); jsonMlsExportCheckbox.setChecked(recentFileTypes.contains(FileType.JsonMls)); final CheckBox compressExportCheckbox = dialogLayout.findViewById(R.id.compress_export_dialog_checkbox); compressExportCheckbox.setChecked(recentFileTypes.contains(FileType.Compress)); AlertDialog alertDialog = new AlertDialog.Builder(this).setView(dialogLayout).create(); alertDialog.setCanceledOnTouchOutside(true); alertDialog.setCancelable(true); alertDialog.setTitle(R.string.export_dialog_format_selection_title); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dialog_export), (dialog, which) -> { List<FileType> selectedFileTypes = new ArrayList<>(); if (csvExportCheckbox.isChecked()) selectedFileTypes.add(FileType.Csv); if (gpxExportCheckbox.isChecked()) selectedFileTypes.add(FileType.Gpx); if (csvOcidExportCheckbox.isChecked()) selectedFileTypes.add(FileType.CsvOcid); if (jsonMlsExportCheckbox.isChecked()) selectedFileTypes.add(FileType.JsonMls); if (compressExportCheckbox.isChecked()) selectedFileTypes.add(FileType.Compress); preferencesProvider.setEnabledExportFileTypes(selectedFileTypes); Timber.d("startExportAsyncTask(): User selected positions: %s", TextUtils.join(",", selectedFileTypes)); if (selectedFileTypes.isEmpty()) { Toast.makeText(getApplication(), R.string.export_toast_no_file_types_selected, Toast.LENGTH_LONG).show(); } else { ExportFileAsyncTask task = new ExportFileAsyncTask(MainActivity.this, new InternalMessageHandler(MainActivity.this), selectedFileTypes); task.execute(); } }); alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dialog_cancel), (dialog, which) -> { // empty }); alertDialog.show(); } else if (StorageUtils.isExternalMemoryPresent()) { Toast.makeText(getApplication(), R.string.export_toast_storage_read_only, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplication(), R.string.export_toast_no_storage, Toast.LENGTH_LONG).show(); } }
Example 20
Source File: MainActivity.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
private void displayNotCompatibleDialog() { // check if displayed in this app run if (showNotCompatibleDialog) { // check if not disabled in preferences boolean showCompatibilityWarningEnabled = MyApplication.getPreferencesProvider().getShowCompatibilityWarning(); if (showCompatibilityWarningEnabled) { TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // check if device contains telephony hardware (some tablets doesn't report even if have) // NOTE: in the future this may need to be expanded when new specific features appear PackageManager packageManager = getPackageManager(); boolean noRadioDetected = !(packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) && (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_GSM) || packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA))); // show dialog if something is not supported if (noRadioDetected) { Timber.d("displayNotCompatibleDialog(): Not compatible because of radio: %s, phone type: %s", noRadioDetected, telephonyManager.getPhoneType()); //use custom layout to show "don't show this again" checkbox AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.from(this); View dialogLayout = inflater.inflate(R.layout.dont_show_again_dialog, null); final CheckBox dontShowAgainCheckbox = (CheckBox) dialogLayout.findViewById(R.id.dont_show_again_dialog_checkbox); dialogBuilder.setView(dialogLayout); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.setCanceledOnTouchOutside(true); alertDialog.setCancelable(true); alertDialog.setTitle(R.string.main_dialog_not_compatible_title); StringBuilder stringBuilder = new StringBuilder(getString(R.string.main_dialog_not_compatible_begin)); if (noRadioDetected) { stringBuilder.append(getString(R.string.main_dialog_no_compatible_mobile_radio_message)); } // text set this way to prevent checkbox from disappearing when text is too long TextView messageTextView = (TextView) dialogLayout.findViewById(R.id.dont_show_again_dialog_textview); messageTextView.setText(stringBuilder.toString()); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { boolean dontShowAgainCheckboxChecked = dontShowAgainCheckbox.isChecked(); Timber.d("displayNotCompatibleDialog(): Don't show again checkbox checked = %s", dontShowAgainCheckboxChecked); if (dontShowAgainCheckboxChecked) { MyApplication.getPreferencesProvider().setShowCompatibilityWarning(false); } } }); alertDialog.show(); } } showNotCompatibleDialog = false; } }