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 showMessageDialogWithNewIntent(final Activity curentActivity, Context context,
        String message, final Class newActivity, final String extras) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {

                    Intent i = new Intent(curentActivity, newActivity);
                    if (extras != null) {
                        Log.i("LOGINSIGNUP", "=extras!=null in showMessageDialog");
                        i.putExtra("OAuthError", true);
                    }/*from   w  w  w  . ja  v  a 2 s  .  c  o m*/
                    Log.i("LOGINSIGNUP", "==after if in showMessageDialog");

                    curentActivity.startActivity(i);
                    //                  curentActivity.finish();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void openAbout(Activity a) {
    Log.d("about", "openAbout has been called");
    //Log.d("context", "context = "+ c.toString());
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(a);

    alertDialogBuilder.setTitle("About");

    alertDialogBuilder.setMessage(// w  w  w .  j a va 2  s  .  c om
            "This app was developed for CS160 at UC Berkeley by:\n\nDominic Kong \nPatrick Lin \nMeghana Seshadri \nJane Sima")
            .setCancelable(true).setNeutralButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

From source file:Main.java

public static void showAlertDialog(Context context, String title, String message, int iconId,
        String textButton) {//  w  w  w .  j  av  a 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

/**
 * Generic error dialog with a close button.
 *//*from w  w w. j  av a 2 s .  c  o  m*/
public static void showDialog(String title, String message, Context context) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setTitle(title);
    alertDialogBuilder.setMessage(message).setCancelable(false).setPositiveButton("Close",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

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//  www.j  ava  2s.com
        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:Main.java

static void showDialog(final Context context, String title, String message, final boolean isFinish) {

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setTitle(title);/*from www. ja va2 s .  c  o  m*/

    // set dialog message
    alertDialogBuilder.setCancelable(false).setMessage(message).setPositiveButton(android.R.string.ok,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    if (isFinish)
                        ((Activity) context).finish();
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.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//from   www .  jav  a 2 s .  co  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:io.trigger.forge.android.modules.contextmenu.API.java

public static void show(final ForgeTask task, @ForgeParam("items") final JsonArray JSONItems)
        throws JSONException {
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(ForgeApp.getActivity(), android.R.style.Theme_Holo));
    final String[] items = toJavaArray(JSONItems);
    builder.setItems(items, new OnClickListener() {
        @Override/*from w ww  . j  a v a2 s . c  o m*/
        public void onClick(DialogInterface dialog, int which) {
            task.success(items[which]);
        }
    });
    AlertDialog toShow = builder.create();
    toShow.show();
}

From source file:Main.java

/**
 * create dialog/*from   w  ww .j a va 2s . c o m*/
 */

public static void callDialog(Context ctx, String msg, String title) {

    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setMessage(msg).setTitle(title).setPositiveButton(android.R.string.ok, null);
    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:Main.java

/**
 * //from   w  ww .j  av  a2 s  .c om
 * @param context
 * @param title
 * @param message
 */
public static void showAlert(Context context, String title, String message) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setTitle(title).setMessage(message).setCancelable(false).setNeutralButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, close
                    // current activity
                    dialog.dismiss();
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();
}