List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:de.feanor.yeoldemensa.ExceptionHandler.java
/** * Displays an exception text to the user, along with explanatory error * message. This error message should be understandable even to * non-programmers and maybe help us when they give feedback. * /* ww w . j a va 2s.c om*/ * Where Exceptions might occur, always use this method! App should never * crash without an info to the user. * * @param e * Exception to display * @param errorMessage * (Commonly understandable) error message to display. */ public static void displayException(Exception e, String errorMessage) { Log.e("yom", errorMessage + ": " + e.getMessage(), e); AlertDialog.Builder builder = new AlertDialog.Builder(YeOldeMensa.context); builder.setMessage(errorMessage + "\n\nDetail: " + e).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.create().show(); }
From source file:Main.java
public static void showAlertDialog(Context context, String title, String message, int iconId, String textButton) {//from w ww. java 2 s . c o m AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); builder.setMessage(message); builder.setCancelable(false); if (iconId > 0) builder.setIcon(iconId); builder.setNegativeButton(textButton, 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 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();/*from ww w . j ava 2s. c om*/ if (exit) { activity.setResult(activity.RESULT_CANCELED); activity.finish(); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.samknows.measurement.util.LoginHelper.java
public static void showErrorDialog(Context c, int messId) { AlertDialog.Builder builder = new AlertDialog.Builder(c); builder.setMessage(messId).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss();// w w w . ja va2 s. c om } }); builder.create().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 w w w . j a va 2 s. co m 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:com.evozi.droidsniff.helper.DialogHelper.java
/** public static void downloadUpdate(Activity context) { try {//w ww .j ava2 s . co 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:Main.java
public static void displayErrorStay(String message, Context context) { // no deals found so display a popup and return to search options AlertDialog.Builder builder = new AlertDialog.Builder(context); // set title//w w w . java 2 s .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(); } }); // create alert dialog AlertDialog alertDialog = builder.create(); // show it alertDialog.show(); }
From source file:com.ecml.ChooseSongActivity.java
/** Show an error dialog with the given message */ public static void showErrorDialog(String message, Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(message);/*from w w w . j a va2 s .c o m*/ builder.setCancelable(false); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alert = builder.create(); alert.show(); }
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 w w w . j av a2 s .c om*/ 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 createCancellableAcceptDialog(Context context, String title, String message, String acceptButtonText, final Runnable onAccept) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title);/*from w ww . j ava 2s.com*/ builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (onAccept != null) onAccept.run(); } }); AlertDialog alert = builder.create(); alert.show(); }