Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:Main.java

public static void mostrarCaixaDialogoSimples(Context context, String titulo, String mensagem) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(titulo);/*from ww  w.  ja va 2  s.  co  m*/
    builder.setMessage(mensagem);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

From source file:Main.java

public static void showDialog(final Activity activity, AlertDialog dialog) {
    if (!activity.isFinishing()) {
        dialog.show();
    }/*from   ww w .j  a v  a2  s  .  c om*/
}

From source file:Main.java

public static void alertTurnOnGPS(final Context mContext) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage("Do you want to enable GPS?").setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    mContext.startActivity(
                            new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }/*from www  .ja v a2s. co  m*/
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    dialog.cancel();
                }
            });
    final AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

/**
 * General Purpose AlertDialog*///from  w w w. j a  v a2 s. c om
public static AlertDialog showMessageAlertDialog(Context context, String message, String title,
        DialogInterface.OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(android.R.string.ok, listener);
    AlertDialog dialog = builder.create();
    dialog.show();
    return dialog;
}

From source file:Main.java

/**
 * General Purpose AlertDialog*///from www .j  a  v  a 2  s.c om
public static AlertDialog showMessageAlertDialog(Context context, int message, int title,
        DialogInterface.OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(android.R.string.ok, listener);
    AlertDialog dialog = builder.create();
    dialog.show();
    return dialog;
}

From source file:Main.java

public static void displayAlertDialog(String text, final Context context, final boolean closeActivity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(text);//from   ww w. j  a va2  s .  c o  m
    builder.setCancelable(false);
    builder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            if (closeActivity) {
                ((Activity) context).finish();
            } else {
                dialogInterface.dismiss();
            }
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:Main.java

public static void showOKAlert(Context context, String message) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();/* ww w. ja va  2s  . c  o  m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void showOKAlert(Context context, int messageResourceID) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setMessage(messageResourceID).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();/*from  w w  w .  j  a v  a 2 s.  co  m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void alert(final Activity activity, final String msg, final String ok, final boolean exit) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(msg).setCancelable(false).setPositiveButton(ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();// ww  w.jav a 2  s.  c o m
            if (exit) {
                activity.setResult(activity.RESULT_CANCELED);
                activity.finish();
            }
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

static public void showDialogBox(String message, Context context) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setMessage(message);

    alertDialogBuilder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {

        @Override//from  ww w  .  j a v  a  2  s .  co m
        public void onClick(DialogInterface arg0, int arg1) {

        }
    });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}