Example usage for android.app AlertDialog.Builder setCancelable

List of usage examples for android.app AlertDialog.Builder setCancelable

Introduction

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

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

private void setDeleteDataButton() {
    Preference myDelDataButton = new Preference(this);
    myDelDataButton.setTitle(R.string.sett_deleteData);
    myDelDataButton.setSummary(R.string.sett_deleteDataSumm);
    myDelDataButton.setKey(getString(R.string.sett_key_deleteData));
    myDelDataButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//ww  w. j  a  v  a 2s . co m
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder ensureDialogB = new AlertDialog.Builder(SettingsActivity.this);
            ensureDialogB.setCancelable(false).setMessage(R.string.sett_deleteDataDialog_msg)
                    .setNegativeButton(R.string.sett_deleteDataDialog_negBtn, null).setPositiveButton(
                            R.string.sett_deleteDataDialog_posBtn, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    Toast.makeText(SettingsActivity.this, R.string.sett_toast_delFiles,
                                            Toast.LENGTH_SHORT).show();
                                    GlobalPhoneFuncs.recursiveDeletionInBackgroundThread(
                                            new File(AppData.getExtFolderAppRoot()), false);
                                }
                            });
            ensureDialogB.show();
            return true;
        }
    });
    if (myCat2 != null) {
        myCat2.addPreference(myDelDataButton);
    }
}

From source file:com.semaphore.sm.MainActivity.java

private void readProperties() {
    AlertDialog.Builder ad = new AlertDialog.Builder(this);
    ad.setMessage("System settings maybe will override your personal settings.\nDo you want to continue?");
    ad.setCancelable(false);
    ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            PropTask pt = new PropTask();
            pt.execute(sp);//from   ww  w  .  j av a  2s.  c o m
        }
    });
    ad.setNegativeButton("Cancel", null);
    ad.show();
}

From source file:com.github.howeyc.slideshow.activities.SettingsActivity.java

public void setResetToDefaultButton() {
    Preference myResetButton = new Preference(this);
    myResetButton.setTitle(R.string.sett_resetTitle);
    myResetButton.setSummary(R.string.sett_resetSummary);
    myResetButton.setKey(getString(R.string.sett_key_restoreDefaults));
    myResetButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//from  w w  w .j a  v  a  2 s . c o  m
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder ensureDialogB = new AlertDialog.Builder(SettingsActivity.this);
            ensureDialogB.setCancelable(false).setMessage(R.string.sett_confirmationDialogMessage)
                    .setNegativeButton(R.string.sett_no, null)
                    .setPositiveButton(R.string.sett_yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            debug("in click on yes!");
                            resetSettingsToDefault();
                            Toast.makeText(SettingsActivity.this, R.string.sett_toast_reset, Toast.LENGTH_SHORT)
                                    .show();
                            updateAllFieldTitles();
                        }
                    });
            ensureDialogB.show();
            return true;
        }
    });
    if (myCat2 != null) {
        myCat2.addPreference(myResetButton);
    }

}

From source file:com.semaphore.sm.MainActivity.java

private void checkSU_BB() {
    Commander cm = Commander.getInstance();
    int ret = cm.run("uname -r", true);
    if (ret == 1) {
        AlertDialog.Builder ad = new AlertDialog.Builder(this);
        ad.setMessage("No root access!\nSemaphore Manager needs root access to run.");
        ad.setCancelable(false);
        ad.setPositiveButton("Close", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                MainActivity.this.finish();
            }/*w ww .ja v  a 2s .  c om*/
        });
        ad.show();
    }
    ret = cm.run("uname -r", false);
    if (ret == 1) {
        AlertDialog.Builder ad = new AlertDialog.Builder(this);
        ad.setMessage("No busybox found!\nSemaphore Manager needs busybox to run properly.");
        ad.setCancelable(false);
        ad.setPositiveButton("Close", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                MainActivity.this.finish();
            }
        });
        ad.show();
    } else {
        if (cm.getOutResult().size() > 0)
            SemaphoreVer = cm.getOutResult().get(0);
        else
            SemaphoreVer = "";
    }
}

From source file:com.google.zxing.client.android.history.HistoryActivity.java

public void enviaTodosDados() {
    /*/*from www.  jav a  2  s .  c om*/
     * enviar todos os qr's lidos
     */

    AlertDialog.Builder builder1 = new AlertDialog.Builder(this, 3);
    builder1.setMessage(R.string.enviar_todos);
    builder1.setCancelable(true);
    builder1.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i2) {

            boolean conectado = verificaConexao();
            if (conectado) {
                try {
                    progDialog.setTitle(R.string.alerta_enviando_dados);
                    progDialog.setMessage(
                            getBaseContext().getResources().getString(R.string.alerta_dados_sendo_enviados));
                    progDialog.setIcon(android.R.drawable.ic_menu_upload);
                    progDialog.show();
                    enviarListaHistorico();

                } catch (Exception e) {
                    // TODO: handle exception
                    progDialog.setIcon(android.R.drawable.ic_dialog_alert);
                    progDialog.setTitle(R.string.alerta_erro);
                    progDialog.setMessage(
                            getBaseContext().getResources().getString(R.string.alerta_erro_ao_enviar_dados)
                                    + " - " + e.getMessage());
                    progDialog.dismiss();
                }
            }
            dialog.dismiss();
        }
    });

    builder1.setNegativeButton(R.string.button_cancel, null);
    builder1.show();
}

From source file:com.nuvolect.securesuite.data.SqlSyncTest.java

public void pingPongConfirmDiag(final Activity act) {

    m_act = act;/*from   w  w  w . ja  va 2 s .  co m*/

    if (!WebUtil.companionServerAssigned()) {
        Toast.makeText(act, "Configure companion device for test to operate", Toast.LENGTH_LONG).show();
        return;
    }

    String title = "Pyramid comm test with companion device";
    String message = "This is a non-destructive network performance test. "
            + "Payload size is incrementally increased.";

    AlertDialog.Builder builder = new AlertDialog.Builder(act);
    builder.setTitle(title);
    builder.setMessage(Html.fromHtml(message));
    builder.setIcon(CConst.SMALL_ICON);
    builder.setCancelable(true);

    builder.setPositiveButton("Start test", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            setProgressCallback(m_act, pingPongCallbacks);
            pingPongProgress(act);
            SqlSyncTest.getInstance().init();// Small amount of init on UI thread
            WorkerCommand.quePingTest(m_act);// Heavy lifting on non-UI thread
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            dialog_alert.cancel();
        }
    });
    dialog_alert = builder.create();
    dialog_alert.show();

    // Activate the HTML
    TextView tv = ((TextView) dialog_alert.findViewById(android.R.id.message));
    tv.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog assignFailDialog(Context context, String str) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setTitle(R.string.assign_confirm_title);
    builder.setMessage(str);/*from   w w  w.  j  a  v a 2s  . co  m*/
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            setHints();
        }
    });
    return builder.create();
}

From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java

@Override
public void onBackPressed() {
    final boolean onFragmentBackPressed;
    onFragmentBackPressed = this.mCurrentlyDisplayedFragment != null
            && this.mCurrentlyDisplayedFragment.onBackPressed();
    if (!onFragmentBackPressed) {
        final AlertDialog.Builder b = new AlertDialog.Builder(this);
        b.setMessage(R.string.dialog_quit_message);
        b.setCancelable(true);
        b.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override/*from  www  . j ava2  s .  c  om*/
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                PreviewHolder.getInstance(BrowserPagerActivity.this).recycle();
                finish();
            }
        });
        b.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        final Dialog dialog = b.create();
        if (!this.isFinishing()) {
            dialog.show();
        }
    }
}

From source file:tcc.iesgo.activity.ClientMapActivity.java

@Override
public void onProviderDisabled(String arg0) {
    final AlertDialog.Builder dialog = new AlertDialog.Builder(getParent());
    dialog.setTitle(getString(R.string.gps_disabled));
    dialog.setMessage(getString(R.string.gps_disabled_message));
    dialog.setIcon(R.drawable.gps_enable);
    dialog.setCancelable(false);

    dialog.setPositiveButton(getString(R.string.ad_button_positive), new DialogInterface.OnClickListener() {
        @Override//from w  w  w.j a v a 2  s.  com
        public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(intent);
        }
    });

    dialog.setNegativeButton(getString(R.string.ad_button_negative), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            finish();
        }
    });
    dialog.show();
}

From source file:com.jeremyhaberman.playgrounds.Playgrounds.java

/**
 * Display an error about failing to load playground data. Called by
 * displayErrorTask//from   w ww. j  a v a 2  s  . c  om
 */
protected void displayPlaygroundLoadError() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // builder.setTitle("ERROR");

    builder.setMessage("Error loading playgrounds");
    builder.setCancelable(false);
    builder.setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
            mHandler.post(showPlaygrounds);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog = builder.create();
    alertDialog.show();
    mHandler.sendEmptyMessage(0);
}