Example usage for android.app AlertDialog setCanceledOnTouchOutside

List of usage examples for android.app AlertDialog setCanceledOnTouchOutside

Introduction

In this page you can find the example usage for android.app AlertDialog setCanceledOnTouchOutside.

Prototype

public void setCanceledOnTouchOutside(boolean cancel) 

Source Link

Document

Sets whether this dialog is canceled when touched outside the window's bounds.

Usage

From source file:info.zamojski.soft.towercollector.MainActivity.java

private void startNetworkTypeSystemActivity() {
    try {//from w  ww. j av a2  s.  c  o m
        startActivity(createDataRoamingSettingsIntent());
    } catch (ActivityNotFoundException ex) {
        Log.w("askAndSetGpsEnabled(): Could not open Settings to change network type", ex);
        MyApplication.getAnalytics().sendException(ex, Boolean.FALSE);
        ACRA.getErrorReporter().handleSilentException(ex);
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this)
                .setMessage(R.string.dialog_could_not_open_network_type_settings)
                .setPositiveButton(R.string.dialog_ok, null).create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.setCancelable(true);
        alertDialog.show();
    }
}

From source file:info.zamojski.soft.towercollector.MainActivity.java

public void displayHelpOnClick(View view) {
    int titleId = View.NO_ID;
    int messageId = View.NO_ID;
    switch (view.getId()) {
    case R.id.main_gps_status_tablerow:
        titleId = R.string.main_help_gps_status_title;
        messageId = R.string.main_help_gps_status_description;
        break;//from  w ww .jav a  2s  . c  o m
    case R.id.main_invalid_system_time_tablerow:
        titleId = R.string.main_help_invalid_system_time_title;
        messageId = R.string.main_help_invalid_system_time_description;
        break;
    case R.id.main_stats_today_locations_tablerow:
        titleId = R.string.main_help_today_locations_title;
        messageId = R.string.main_help_today_locations_description;
        break;
    case R.id.main_stats_today_cells_tablerow:
        titleId = R.string.main_help_today_cells_title;
        messageId = R.string.main_help_today_cells_description;
        break;
    case R.id.main_stats_local_locations_tablerow:
        titleId = R.string.main_help_local_locations_title;
        messageId = R.string.main_help_local_locations_description;
        break;
    case R.id.main_stats_local_cells_tablerow:
        titleId = R.string.main_help_local_cells_title;
        messageId = R.string.main_help_local_cells_description;
        break;
    case R.id.main_stats_global_locations_tablerow:
        titleId = R.string.main_help_global_locations_title;
        messageId = R.string.main_help_global_locations_description;
        break;
    case R.id.main_stats_global_cells_tablerow:
        titleId = R.string.main_help_global_cells_title;
        messageId = R.string.main_help_global_cells_description;
        break;
    case R.id.main_last_network_type_tablerow:
        titleId = R.string.main_help_last_network_type_title;
        messageId = R.string.main_help_last_network_type_description;
        break;
    case R.id.main_last_cell_id_tablerow:
        titleId = R.string.main_help_last_cell_id_title;
        messageId = R.string.main_help_last_cell_id_description;
        break;
    case R.id.main_last_lac_tablerow:
        titleId = R.string.main_help_last_lac_title;
        messageId = R.string.main_help_last_lac_description;
        break;
    case R.id.main_last_mcc_tablerow:
        titleId = R.string.main_help_last_mcc_title;
        messageId = R.string.main_help_last_mcc_description;
        break;
    case R.id.main_last_mnc_tablerow:
        titleId = R.string.main_help_last_mnc_title;
        messageId = R.string.main_help_last_mnc_description;
        break;
    case R.id.main_last_signal_strength_tablerow:
        titleId = R.string.main_help_last_signal_strength_title;
        messageId = R.string.main_help_last_signal_strength_description;
        break;
    case R.id.main_last_latitude_tablerow:
        titleId = R.string.main_help_last_latitude_title;
        messageId = R.string.main_help_last_latitude_description;
        break;
    case R.id.main_last_longitude_tablerow:
        titleId = R.string.main_help_last_longitude_title;
        messageId = R.string.main_help_last_longitude_description;
        break;
    case R.id.main_last_gps_accuracy_tablerow:
        titleId = R.string.main_help_last_gps_accuracy_title;
        messageId = R.string.main_help_last_gps_accuracy_description;
        break;
    case R.id.main_last_date_time_tablerow:
        titleId = R.string.main_help_last_date_time_title;
        messageId = R.string.main_help_last_date_time_description;
        break;
    }
    Log.d("displayHelpOnClick(): Displaying help for title: %s", titleId);
    if (titleId != View.NO_ID && messageId != View.NO_ID) {
        AlertDialog dialog = new AlertDialog.Builder(this).setTitle(titleId).setMessage(messageId)
                .setPositiveButton(R.string.dialog_ok, null).create();
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        dialog.show();
    }
}

From source file:net.smartpager.android.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch (item.getItemId()) {

    case R.id.item_add_contact:
        String[] items = new String[] { getString(R.string.new_group), getString(R.string.new_contact) };
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        builder.setCancelable(true);//from   w w  w. j  ava  2  s. c o  m
        builder.setItems(items, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                case 0:
                    createNewGroup();
                    break;
                case 1:
                    createNewContact();
                    break;
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.show();
        break;
    case R.id.item_clear_archive:
        AlertFragmentDialogYesNO dialog = AlertFragmentDialogYesNO.newInstance(getApplicationContext(),
                getString(R.string.clear_archive), getString(R.string.are_you_sure_you_want_to_clear_archive),
                "", true, this);
        dialog.show(getSupportFragmentManager(), FragmentDialogTag.ClearArchive.name());

        break;
    case R.id.item_settings:
        startActivity(new Intent(this, SettingsActivity.class));
        break;
    case R.id.item_info:
        startActivity(new Intent(this, InfoActivity.class));
        break;
    case R.id.item_archive_all:
        AlertFragmentDialogYesNO dialog1 = AlertFragmentDialogYesNO.newInstance(getApplicationContext(),
                getString(R.string.archive_all), getString(R.string.move_read_and_sent), "", true, this);
        dialog1.show(getSupportFragmentManager(), FragmentDialogTag.ArchiveAllRead.name());
        break;
    default:
        return false;
    }
    return true;
}

From source file:info.zamojski.soft.towercollector.MainActivity.java

private void askAndSetGpsEnabled() {
    if (GpsUtils.isGpsEnabled(getApplication())) {
        Log.d("askAndSetGpsEnabled(): GPS enabled");
        isGpsEnabled = true;/*from w w  w . j  a v  a  2s .  co  m*/
        showAskForLocationSettingsDialog = false;
    } else {
        Log.d("askAndSetGpsEnabled(): GPS disabled, asking user");
        isGpsEnabled = false;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.dialog_want_enable_gps)
                .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Log.d("askAndSetGpsEnabled(): display settings");
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        try {
                            startActivity(intent);
                            showAskForLocationSettingsDialog = true;
                        } catch (ActivityNotFoundException ex1) {
                            intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
                            try {
                                startActivity(intent);
                                showAskForLocationSettingsDialog = true;
                            } catch (ActivityNotFoundException ex2) {
                                Log.w("askAndSetGpsEnabled(): Could not open Settings to enable GPS");
                                MyApplication.getAnalytics().sendException(ex2, Boolean.FALSE);
                                ACRA.getErrorReporter().handleSilentException(ex2);
                                AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this)
                                        .setMessage(R.string.dialog_could_not_open_gps_settings)
                                        .setPositiveButton(R.string.dialog_ok, null).create();
                                alertDialog.setCanceledOnTouchOutside(true);
                                alertDialog.setCancelable(true);
                                alertDialog.show();
                            }
                        } finally {
                            dialog.dismiss();
                        }
                    }
                }).setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Log.d("askAndSetGpsEnabled(): cancel");
                        dialog.cancel();
                        if (GpsUtils.isGpsEnabled(getApplication())) {
                            Log.d("askAndSetGpsEnabled(): provider enabled in the meantime");
                            startCollectorServiceWithCheck();
                        } else {
                            isGpsEnabled = false;
                            showAskForLocationSettingsDialog = false;
                        }
                    }
                });
        AlertDialog dialog = builder.create();
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        dialog.show();
    }
}

From source file:org.catrobat.catroid.ui.dialogs.NewSpriteDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_new_object, null);
    setupPaintroidButton(dialogView);//w w w. j a va 2s . com
    setupGalleryButton(dialogView);
    setupCameraButton(dialogView);
    setupMediaLibraryButton(dialogView);

    AlertDialog dialog = null;
    AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView)
            .setTitle(R.string.new_sprite_dialog_title);
    if (wizardStep == DialogWizardStep.STEP_1) {
        dialog = createDialogStepOne(dialogBuilder);
    } else if (wizardStep == DialogWizardStep.STEP_2) {
        dialog = createDialogStepTwo(dialogBuilder);
    }
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(final DialogInterface dialog) {
            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (handleOkButton()) {
                        dialog.dismiss();
                    }
                }
            });
        }
    });
    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    return dialog;
}

From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    dialogView = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_new_object,
            null);/* ww  w. j a v a2  s.  c  om*/
    setupPaintroidButton(dialogView);
    setupGalleryButton(dialogView);
    setupCameraButton(dialogView);

    AlertDialog dialog = null;
    AlertDialog.Builder dialogBuilder = new CustomAlertDialogBuilder(getActivity()).setView(dialogView)
            .setTitle(hku.fyp14017.blencode.R.string.new_sprite_dialog_title);
    if (wizardStep == DialogWizardStep.STEP_1) {
        dialog = createDialogStepOne(dialogBuilder);
    } else if (wizardStep == DialogWizardStep.STEP_2) {
        dialog = createDialogStepTwo(dialogBuilder);
    }
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(final DialogInterface dialog) {
            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (handleOkButton()) {
                        dialog.dismiss();
                    }
                }
            });
        }
    });
    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    return dialog;
}

From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java

private void displayAlertWithMessage(String errorcode) {
    String errorMessage = getResources().getString(R.string.alert_message_write_error) + "\n"
            + getResources().getString(R.string.alert_message_write_error_code) + errorcode + "\n"
            + getResources().getString(R.string.alert_message_try_again);
    AlertDialog alert;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    TextView myMsg = new TextView(getActivity());
    myMsg.setText(errorMessage);/*w  ww  .  j  a  v  a 2 s  .  c  om*/
    myMsg.setGravity(Gravity.CENTER_HORIZONTAL);
    builder.setView(myMsg);
    builder.setTitle(getActivity().getResources().getString(R.string.app_name)).setCancelable(false)
            .setPositiveButton(getActivity().getResources().getString(R.string.alert_message_exit_ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    });
    alert = builder.create();
    alert.setCanceledOnTouchOutside(false);
    alert.show();
}

From source file:com.romanenco.gitt.BrowserActivity.java

private void deleteThisRepo() {
    AlertDialog dlg = new AlertDialog.Builder(this).setMessage(R.string.confirm_repo_delete)
            .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    DAO dao = new DAO(BrowserActivity.this);
                    dao.open(true);//from   ww w . j a  v  a 2 s . co  m
                    dao.delete(current.getFolder());
                    dao.close();
                    Intent delete = new Intent(BrowserActivity.this, GitService.class);
                    delete.putExtra(GitService.COMMAND, GitService.Command.Delete);
                    delete.putExtra(GitService.REPO, current);
                    startService(delete);
                    Intent main = new Intent(BrowserActivity.this, MainActivity.class);
                    main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(main);
                }
            }).setNegativeButton(getString(android.R.string.cancel), null).create();
    dlg.setCanceledOnTouchOutside(false);
    dlg.show();
}

From source file:no.barentswatch.fiskinfo.BaseActivity.java

/**
 * This function creates a "<code>positive</code>:see google docs" pop up
 * dialog which takes in the context of the current activity
 * //  w ww  .j a va 2 s  .  co m
 * @param activityContext
 *            the context of the current activity
 * @param rPathToTitleOfPopup
 *            The R.path to the title
 * @param rPathToTextInTheBodyOfThePopup
 *            The R.path to the text which will be contained in the body
 */
public void createNewPositiveDialog(Context activityContext, int rPathToTitleOfPopup,
        int rPathToTextInTheBodyOfThePopup) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activityContext);
    builder.setTitle(rPathToTitleOfPopup);
    builder.setMessage(rPathToTextInTheBodyOfThePopup);
    builder.setPositiveButton("OK", null);
    AlertDialog dialog = builder.show();
    dialog.setCanceledOnTouchOutside(false);

    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            actionBar.setSelectedNavigationItem(adapter.getCount());
        }
    });

    TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
    messageView.setGravity(Gravity.CENTER);
}

From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java

/**
 * ??????/*w ww  . j a v  a2s.c o m*/
 * @param purchase
 */
void alert(final Purchase purchase) {
    final AlertDialog d = new AlertDialog.Builder(this).create();
    d.show();
    d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle"));
    d.setCanceledOnTouchOutside(false);
    d.setCancelable(false);
    TextView retry = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure"));
    retry.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_retry")));
    retry.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // ?
            d.dismiss();
            setWaitScreen(true);
            check(purchase);
        }
    });
    TextView close = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle"));
    close.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_close")));
    close.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            d.dismiss();
            setResultInfo(OASISPlatformConstant.RESULT_EXCEPTION_GOOGLEPAY_EXCEPTION,
                    "?????");
            close();
        }
    });

    TextView content = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content"));
    content.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_content")));

}