List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:com.evozi.droidsniff.helper.DialogHelper.java
public static void installBusyBox(Activity context) { DialogHelper.context = context;//w w w . j a v a 2 s . 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:it.mb.whatshare.Dialogs.java
/** * Shows a dialog informing the user that the action she's trying to perform * requires an Internet connection which is not available at the moment. * //from ww w .j av a2 s . c om * @param activity * the caller activity * @param whyItsNeeded * the resource ID within <tt>strings.xml</tt> that explains to * the user why an Internet connection is needed by the operation * @param finishActivityOnOk * whether the caller activity must be {@link Activity#finish()} * 'ed after the user hides the dialog */ public static void noInternetConnection(final FragmentActivity activity, final int whyItsNeeded, final boolean finishActivityOnOk) { new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder; if (finishActivityOnOk) { builder = getNoUiBuilder(activity); } else { builder = getBuilder(activity); } builder.setMessage(getString(R.string.no_internet_connection, getString(whyItsNeeded))); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(!finishActivityOnOk); return dialog; } }.show(activity.getSupportFragmentManager(), "no_internet"); }
From source file:fr.cph.chicago.util.Util.java
/** * Function to show settings alert dialog *//*from w ww .j a v a 2 s. co m*/ static void showSettingsAlert(@NonNull final Activity activity) { new Thread() { public void run() { activity.runOnUiThread(() -> { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder.setTitle("GPS settings"); alertDialogBuilder.setMessage( "GPS is not enabled. Do you want to go to settings main.java.fr.cph.chicago.res.menu?"); alertDialogBuilder.setCancelable(false).setPositiveButton("Yes", (dialog, id) -> { final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); activity.startActivity(intent); }).setNegativeButton("No", (dialog, id) -> dialog.cancel()); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }); } }.start(); }
From source file:Main.java
public static AlertDialog showTutorialDialog(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Watch a YouTube video tutorial?"); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setPositiveButton("Watch", new DialogInterface.OnClickListener() { @Override/*w w w . j a v a 2s. c o m*/ public void onClick(DialogInterface dialog, int which) { PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false) .commit(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=LhiSWE5-ezM")); context.startActivity(browserIntent); } }); builder.setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false) .commit(); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); return alert; }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a continue / cancel dialog.//from w ww . j a v a 2 s . com * @param context The current context. * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onContinue The dialog listener for the continue button. * @param onCancel The dialog listener for the cancel button. */ public static void showContinueCancelDialog(Context context, int icon, String title, String message, DialogInterface.OnClickListener onContinue, DialogInterface.OnClickListener onCancel) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(title); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Continue), onContinue); builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), onCancel); AlertDialog alert = builder.create(); alert.show(); }
From source file:nl.mpcjanssen.simpletask.util.Util.java
public static Dialog createSingleChoiceDialog(Context cxt, CharSequence[] keys, String[] values, int selected, Integer titleId, Integer iconId, final OnSingleChoiceDialogListener listener) { assert (values.length == keys.length); AlertDialog.Builder builder = new AlertDialog.Builder(cxt); if (iconId != null) { builder.setIcon(iconId);// w w w .j a v a 2 s . c om } if (titleId != null) { builder.setTitle(titleId); } final String[] res = values; final int checkedItem = selected; builder.setSingleChoiceItems(keys, checkedItem, null); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { int index = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); listener.onClick(res[index]); } }); builder.setNegativeButton(R.string.cancel, null); return builder.create(); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a dialog informing the user that no outbound device is currently * configured, and takes the user to the {@link PairOutboundActivity}. * /* ww w .j a v a 2s. c om*/ * @param activity * the caller activity */ public static void noPairedDevice(final FragmentActivity activity) { new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getNoUiBuilder(activity); builder.setMessage(getString(R.string.no_paired_device)); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(activity, PairOutboundActivity.class); startActivity(i); } }); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); return dialog; } }.show(activity.getSupportFragmentManager(), "no paired device"); }
From source file:com.todotxt.todotxttouch.util.Util.java
public static Dialog createMultiChoiceDialog(Context cxt, CharSequence[] keys, boolean[] values, Integer titleId, Integer iconId, final OnMultiChoiceDialogListener listener) { final boolean[] res; if (values == null) { res = new boolean[keys.length]; } else {/*from w w w .j a v a 2s . co m*/ res = values; } AlertDialog.Builder builder = new AlertDialog.Builder(cxt); if (iconId != null) { builder.setIcon(iconId); } if (titleId != null) { builder.setTitle(titleId); } builder.setMultiChoiceItems(keys, values, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { res[whichButton] = isChecked; } }); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { listener.onClick(res); } }); builder.setNegativeButton(R.string.cancel, null); return builder.create(); }
From source file:nl.mpcjanssen.simpletask.util.Util.java
public static Dialog createMultiChoiceDialog(Context cxt, CharSequence[] keys, boolean[] values, Integer titleId, Integer iconId, final OnMultiChoiceDialogListener listener) { final boolean[] res; if (values == null) { res = new boolean[keys.length]; } else {//from w ww . j a v a 2 s. c om res = values; } AlertDialog.Builder builder = new AlertDialog.Builder(cxt); if (iconId != null) { builder.setIcon(iconId); } if (titleId != null) { builder.setTitle(titleId); } builder.setMultiChoiceItems(keys, values, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { res[whichButton] = isChecked; } }); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { listener.onClick(res); } }); builder.setNegativeButton(R.string.cancel, null); return builder.create(); }
From source file:hongik.android.project.best.ReviewActivity.java
public void showAlertDialog() { AlertDialog.Builder alert_confirm = new AlertDialog.Builder(this); alert_confirm.setMessage("Please write a review : about " + sname).setCancelable(true); AlertDialog alert = alert_confirm.create(); alert.show();/*from ww w . java 2 s. c o m*/ }