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:Main.java

/**
 * Shows the status in Dialog./* w w  w.j a va 2s  .  c om*/
 * 
 * @param context
 * @param message
 */
public static void showStatus(Activity activity, String message, String title) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setCancelable(false);
    dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    dialog.show();
}

From source file:Main.java

/**
 * Will construct the AlertDialog.Builder object for convenience
 * //from  w  ww .  ja v  a  2 s .co m
 * @param context
 *            Application Context
 * @param message
 *            Message to be displayed.
 * @return AlertDialog.Builder object with the message set.
 */
public static AlertDialog.Builder getDialogForStatus(Activity activity, String message, String title) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
    dialog.setCancelable(false);
    if (!TextUtils.isEmpty(title)) {
        dialog.setTitle(title);
    }

    dialog.setMessage(message);
    return dialog;
}

From source file:Main.java

public static AlertDialog newYesNoDialog(final Activity activity, String dialogTitle, String screenMessage,
        int iconResourceId, OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setCancelable(false);
    builder.setPositiveButton(android.R.string.yes, listener);
    builder.setNegativeButton(android.R.string.no, listener);

    builder.setTitle(dialogTitle);/*  www  . j a v  a 2 s . c  o m*/
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}

From source file:Main.java

public static void isGPSActivated(final Context context) {
    LocationManager lm = null;//from w w  w.j  av  a  2 s . com
    boolean gpsEnabled = false;
    if (lm == null)
        lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    try {
        gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    } catch (Exception ex) {
    }

    if (!gpsEnabled) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(context);

        dialog.setCancelable(false);
        dialog.show();

    }
}

From source file:Main.java

public static AlertDialog newYesNoDialog(Context context, String s, String s1, int i,
        android.content.DialogInterface.OnClickListener onclicklistener) {
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setPositiveButton(0x1040013, onclicklistener);
    builder.setNegativeButton(0x1040009, onclicklistener);
    builder.setTitle(s);/*from   w  w w . j av a  2s. c om*/
    builder.setMessage(s1);
    builder.setIcon(i);
    return builder.create();
}

From source file:Main.java

/**
 * Shows the status in Dialog./*from  w  ww.  j a  va 2s  .  c  o m*/
 * 
 * @param context
 * @param message
 */
public static void showStatus(Activity activity, String message, String title) {
    android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(activity);
    dialog.setCancelable(false);
    dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    dialog.show();
}

From source file:Main.java

public static AlertDialog.Builder createAlertDialog(Context context, String title, View dialogView) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);/*from   w  w  w  . jav a 2 s .  c o  m*/
    builder.setCancelable(false);
    builder.setView(dialogView);
    return builder;
}

From source file:Main.java

public static void showProgressDialog(Context mCtx, String msg) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mCtx);
    builder.setMessage(msg);//from   w  w w  .j a  v a2  s. c o m
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:Main.java

public static AlertDialog newMessageDialog(Context context, String s, String s1, int i) {
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setPositiveButton("Okay", new android.content.DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialoginterface, int j) {
            dialoginterface.dismiss();/*from  w  w w .ja va 2  s.c om*/
        }

    });
    builder.setTitle(s);
    builder.setMessage(s1);
    builder.setIcon(i);
    return builder.create();
}

From source file:Main.java

public static AlertDialog newMessageDialog(final Activity activity, String dialogTitle, String screenMessage,
        int iconResourceId) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setCancelable(false);
    builder.setPositiveButton("Okay", new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();//  w  ww. j  ava 2s  .  c o m
        }
    });

    builder.setTitle(dialogTitle);
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}