List of usage examples for android.app AlertDialog show
public void show()
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard yes / no dialog./* w w w . ja v a2s.c om*/ * @param context The current context. * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onYes The dialog listener for the yes button. */ public static void showYesNoDialog(Context context, int icon, int title, int message, DialogInterface.OnClickListener onYes) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(context.getResources().getString(title)); builder.setMessage(context.getResources().getString(message)); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Yes), onYes); builder.setNegativeButton(context.getResources().getString(R.string.Commons_No), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard Ok / Cancel dialog. * @param context The current context.//from w w w .j a v a 2 s. c o m * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onYes The dialog listener for the yes button. */ public static void showOkCancelDialog(Context context, int icon, String title, String message, DialogInterface.OnClickListener onYes) { 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_Ok), onYes); builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.pdftron.pdf.utils.Utils.java
public static void showAlertDialogWithLink(Context context, String message, String title) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(Html.fromHtml(message)).setCancelable(true).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override/*from www . j a v a 2 s. co m*/ public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); if (title.length() > 0) { builder.setTitle(title); } final AlertDialog d = builder.create(); d.show(); // Make the textview clickable. Must be called after show() ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:nya.miku.wishmaster.http.cloudflare.CloudflareUIHandler.java
/** * ?-? Cloudflare.// w w w.jav a 2 s . c o m * * @param e ? {@link CloudflareException} * @param chan * @param activity ?, ? ( ? ? ), * ? ? WebView ? Anti DDOS ? javascript. * ??? ? UI ({@link Activity#runOnUiThread(Runnable)}) * @param cfTask ?? * @param callback ? {@link Callback} */ static void handleCloudflare(final CloudflareException e, final HttpChanModule chan, final Activity activity, final CancellableTask cfTask, final InteractiveException.Callback callback) { if (cfTask.isCancelled()) return; if (!e.isRecaptcha()) { // ? anti DDOS if (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) { //? ? ?? , ? ? ? // ?, ? ChanModule, // ? ? () cloudflare ? ? // ? ? ? ? ? CloudflareChecker while (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) Thread.yield(); if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); return; } Cookie cfCookie = CloudflareChecker.getInstance().checkAntiDDOS(e, chan.getHttpClient(), cfTask, activity); if (cfCookie != null) { chan.saveCookie(cfCookie); if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } } else if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(activity.getString(R.string.error_cloudflare_antiddos)); } }); } } else { // ? final Recaptcha recaptcha; try { recaptcha = CloudflareChecker.getInstance().getRecaptcha(e, chan.getHttpClient(), cfTask); } catch (RecaptchaException recaptchaException) { if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(activity.getString(R.string.error_cloudflare_get_captcha)); } }); return; } if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @SuppressLint("InflateParams") @Override public void run() { Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new ContextThemeWrapper(activity, R.style.Neutron_Medium) : activity; View view = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_cloudflare_captcha, null); ImageView captchaView = (ImageView) view.findViewById(R.id.dialog_captcha_view); final EditText captchaField = (EditText) view.findViewById(R.id.dialog_captcha_field); captchaView.setImageBitmap(recaptcha.bitmap); DialogInterface.OnClickListener process = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (cfTask.isCancelled()) return; PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() { @Override public void run() { String answer = captchaField.getText().toString(); Cookie cfCookie = CloudflareChecker.getInstance().checkRecaptcha(e, (ExtendedHttpClient) chan.getHttpClient(), cfTask, recaptcha.challenge, answer); if (cfCookie != null) { chan.saveCookie(cfCookie); if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } } else { // (?, , ) handleCloudflare(e, chan, activity, cfTask, callback); } } }).start(); } }; DialogInterface.OnCancelListener onCancel = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { callback.onError(activity.getString(R.string.error_cloudflare_cancelled)); } }; if (cfTask.isCancelled()) return; final AlertDialog recaptchaDialog = new AlertDialog.Builder(dialogContext).setView(view) .setPositiveButton(R.string.dialog_cloudflare_captcha_check, process) .setOnCancelListener(onCancel).create(); recaptchaDialog.getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); recaptchaDialog.setCanceledOnTouchOutside(false); recaptchaDialog.show(); captchaView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { recaptchaDialog.dismiss(); if (cfTask.isCancelled()) return; PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() { @Override public void run() { handleCloudflare(e, chan, activity, cfTask, callback); } }).start(); } }); } }); } }
From source file:com.renren.api.connect.android.Util.java
/** * ???UI/* w w w. j av a2 s . c o m*/ * * @param context * @param title * @param text */ public static void showAlert(Context context, String title, String text, boolean showOk) { AlertDialog alertDialog = new Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(text); if (showOk) { OnClickListener listener = null; alertDialog.setButton2("", listener); } alertDialog.show(); }
From source file:com.iStudy.Study.Renren.Util.java
/** * ???UI/*from w w w .j a v a2s.c om*/ * * @param context * @param title * @param text */ @SuppressWarnings("deprecation") public static void showAlert(Context context, String title, String text, boolean showOk) { AlertDialog alertDialog = new Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(text); if (showOk) { OnClickListener listener = null; alertDialog.setButton2("", listener); } alertDialog.show(); }
From source file:com.spoiledmilk.cykelsuperstier.navigation.SMRouteNavigationActivity.java
public static void showRouteNoBreakDialog(final Context context, AlertDialog dialog) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(CykelsuperstierApplication.getString("no_route")); builder.setMessage(CykelsuperstierApplication.getString("cannot_broken")); builder.setPositiveButton("OK", new OnClickListener() { @Override/*from w w w. j a va2 s. c o m*/ public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); } }); dialog = builder.create(); dialog.setCancelable(false); dialog.show(); }
From source file:de.wikilab.android.friendica01.Max.java
public static void alert(Context ctx, String text, String title, String okButtonText) { AlertDialog ad = new AlertDialog.Builder(ctx).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage(Html.fromHtml(text));/* w ww . j a va 2s . com*/ ad.setTitle(title); ad.setButton(okButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); ((TextView) ad.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.max2idea.android.fwknop.Fwknop.java
public static void UIAlert(String title, String body, Activity activity) { AlertDialog ad; ad = new AlertDialog.Builder(activity).create(); ad.setTitle(title);/* w w w . j a v a2 s . com*/ ad.setMessage(body); ad.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); ad.show(); }
From source file:Main.java
public static void ShowSoftInfoDialog(final Context context, String title, String msg) { AlertDialog alertDialog = new AlertDialog.Builder(context).setIcon(android.R.attr.alertDialogIcon) .setTitle(title).setMessage(msg).setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ }//from w ww . jav a 2 s .com }).setNeutralButton("Email", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Uri uri = Uri.parse("mailto:atgczcl@163.com"); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri); context.startActivity(emailIntent); /* User clicked Something so do some stuff */ } }).create(); alertDialog.show(); }