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 displayError(String message, final Class<?> activity, final Context context) {
    // no deals found so display a popup and return to search options
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    // set title/*from ww  w .  j  a v a 2s.c  o m*/
    builder.setTitle("No Results");

    // set dialog message
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    Intent i = new Intent(context, activity);
                    ((Activity) (context)).finish();
                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);
                    context.startActivity(i);
                }
            });
    // create alert dialog
    AlertDialog alertDialog = builder.create();

    // show it
    alertDialog.show();
}

From source file:Main.java

public static void alertMessage(Context context, String msg) {
    AlertDialog alertBuilder = new AlertDialog.Builder(context).create();
    alertBuilder.setMessage(msg);/*from  w  ww. j  a va 2  s .  co  m*/
    alertBuilder.show();
}

From source file:Main.java

public static void showDialogOkWithGoBack(String title, String message, final Activity activity) {
    if (activity.getApplicationContext() != null) {
        AlertDialog.Builder adb = new AlertDialog.Builder(activity);
        adb.setTitle(title);/*from www.  j  a v a2  s. c om*/
        adb.setMessage(message);
        adb.setCancelable(false);
        adb.setNeutralButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
                //activity.onBackPressed();
            }
        });
        AlertDialog ad = adb.create();
        ad.setVolumeControlStream(AudioManager.STREAM_MUSIC);
        ad.show();
    }
}

From source file:Main.java

public static void showAlertError(Context context, String Error) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle("Error");
    alertDialog.setMessage(Error);
    alertDialog.show();
}

From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java

/**
 * Show alert message// w  w w.j  ava  2 s .  co  m
 *
 * @param context
 * @param title
 * @param message
 */
public static void showAlertMessage(Context context, String title, String message) {

    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(context, R.style.AlertDialogCustom));
    builder.setTitle(title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(message).setCancelable(true)
            .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.evozi.droidsniff.helper.DialogHelper.java

/**
public static void downloadUpdate(Activity context) {
   try {/*  ww w  .  j av a2 s  .c o m*/
 String versionStr = getContentFromWeb("http://apps.evozi.com/android/droidsniff/version.php");
 int versionWeb = Integer.valueOf(versionStr);
 PackageManager manager = context.getPackageManager();
 PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
 int myVersion = info.versionCode;
 if (myVersion < versionWeb) {
    DialogHelper.context = context;
    String message = context.getString(R.string.updatetext);
    message += getContentFromWeb("http://apps.evozi.com/android/droidsniff/changelog.php");
        
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(message).setCancelable(false)
          .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
             }
          });
    AlertDialog alert = builder.create();
    alert.show();
 }
   } catch (Exception e) {
 Log.e(Constants.APPLICATION_TAG, "Error while checking update: ", e);
   }
}
**/

public static void showUnrooted(Activity context) {
    DialogHelper.context = context;
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(R.string.unrooted).setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.evozi.droidsniff.helper.DialogHelper.java

public static void clearBlacklist(Activity context) {
    DialogHelper.context = context;//  w  w w  .java  2  s . com
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(R.string.clear_blacklist).setCancelable(false)
            .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    DBHelper.clearBlacklist(DialogHelper.context);
                    AuthHelper.clearBlacklist();
                }
            }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.evozi.droidsniff.helper.DialogHelper.java

public static void installBusyBox(Activity context) {
    DialogHelper.context = context;//  ww  w.j a  v  a  2s.  c  o m
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(R.string.installbusybox).setCancelable(false)
            .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent goToMarket = null;
                    goToMarket = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=stericson.busybox"));
                    DialogHelper.context.startActivity(goToMarket);
                    dialog.cancel();
                }
            }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void displayAlert(Context context, String title, String message, String buttonText,
        DialogInterface.OnClickListener buttonOnclick) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).setPositiveButton(buttonText, buttonOnclick)
            .setTitle(title).setMessage(message).create();

    alertDialog.show();
}

From source file:Main.java

public static void showAlert(Context context, String title, String text) {
    AlertDialog alertDialog = new Builder(context).create();
    alertDialog.setTitle(title);/*  ww w  .  ja v  a  2  s.  co  m*/
    alertDialog.setMessage(text);
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
}