List of usage examples for android.app AlertDialog show
public void show()
From source file:Main.java
public static void showAlertDialog(Context context, String title, String message) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setCancelable(true);//from ww w . ja v a 2 s . c om dialog.setMessage(message); dialog.setTitle(title); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog.show(); }
From source file:Main.java
public static void displayAlert(Context context, String title, String message, String buttonText) { if (null == context || !(context instanceof Activity)) { return;/* www. j a v a 2s . co m*/ } final Activity activity = (Activity) context; AlertDialog alertDialog = new AlertDialog.Builder(activity) .setPositiveButton(buttonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setTitle(title).setMessage(message).create(); if (!activity.isFinishing()) { alertDialog.show(); } }
From source file:Main.java
private static void showBackupDialog(final Context context, String message) { AlertDialog.Builder builder;//from w w w .j a va 2 s.c om AlertDialog alertDialog; builder = new AlertDialog.Builder(context); builder.setMessage(message).setCancelable(true).setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alertDialog = builder.create(); alertDialog.show(); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void showAlert(final String title, final String msg, final Context context) { Activity a = (Activity) context;//from w w w . j a v a 2s . co m a.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(msg); alertDialog.setButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }); alertDialog.show(); } }); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void alertDialog(final Context context, final int mensagem) { try {// ww w . java2 s .c o m AlertDialog dialog = new AlertDialog.Builder(context).setTitle( // context.getString(R.string.app_name)).setMessage(mensagem).create(); "Teste").setMessage(mensagem).create(); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); dialog.show(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } }
From source file:Main.java
@SuppressWarnings("deprecation") public static void alertDialog(final Context context, final String mensagem) { try {//from ww w .j a v a2 s .c om AlertDialog dialog = new AlertDialog.Builder(context).setTitle( // context.getString(R.string.app_name)).setMessage(mensagem).create(); "Teste").setMessage(mensagem).create(); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); dialog.show(); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } }
From source file:br.unicamp.busfinder.ServerOperations.java
public static void nextBuses(final String title, final Context c) { int stopid = Integer.parseInt(title.split("_")[0]); String req = BusFinderActivity.SERVER + "getNextBus?stopid="; JSONArray jar = getJSON(req + stopid); String display = ""; try {//from ww w. j av a 2 s .com for (int i = 0; i < jar.length(); i++) { JSONObject jos = jar.getJSONObject(i); String circular = jos.getString("circular"); String time = jos.getString("time"); display += "--" + circular + "------" + time + "\n"; } final String display_ = display; AlertDialog dialog = new AlertDialog.Builder(c).create(); dialog.setTitle(title); dialog.setMessage(display_); dialog.setCanceledOnTouchOutside(true); dialog.show(); return; } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } Toast.makeText(c, "Error or no Connection ..", Toast.LENGTH_SHORT).show(); }
From source file:Main.java
public static void displayAlert4SingleChoice2(Context context, String title, boolean cancelable, String[] selectNames, final DialogInterface.OnClickListener onClickListener) { AlertDialog accountDlg = new AlertDialog.Builder(context).setTitle(title).setCancelable(cancelable) .setItems(selectNames, new OnClickListener() { @Override/*from w ww . j a va2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { if (null != onClickListener) { onClickListener.onClick(dialog, which); } dialog.dismiss(); } }).create(); accountDlg.show(); }
From source file:fr.cph.chicago.util.Util.java
/** * Function to show settings alert dialog *//*from w ww .j a v a 2 s .c om*/ 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 void showInfoDialog(String text, final Context context) { String ok_text = "Ok"; AlertDialog infoDialog = new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_info) .setItems(null, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/*from w w w . j a v a2 s . c o m*/ }).setTitle("Info").setMessage(text).setPositiveButton(ok_text, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create(); infoDialog.show(); }