Example usage for android.content DialogInterface cancel

List of usage examples for android.content DialogInterface cancel

Introduction

In this page you can find the example usage for android.content DialogInterface cancel.

Prototype

void cancel();

Source Link

Document

Cancels the dialog, invoking the OnCancelListener .

Usage

From source file:com.google.sample.cast.refplayer.utils.Utils.java

/**
 * Shows an error dialog with a given text message.
 *///from w  w  w  .  ja  v a2  s  . c o m
public static void showErrorDialog(Context context, String errorString) {
    new AlertDialog.Builder(context).setTitle(R.string.error).setMessage(errorString)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create().show();
}

From source file:com.google.sample.cast.refplayer.utils.Utils.java

/**
 * Shows an "Oops" error dialog with a text provided by a resource ID
 *//*from w ww . ja  v a  2s  .  c  o  m*/
public static void showOopsDialog(Context context, int resourceId) {
    new AlertDialog.Builder(context).setTitle(R.string.oops).setMessage(context.getString(resourceId))
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).setIcon(R.drawable.ic_action_alerts_and_states_warning).create().show();
}

From source file:com.hectorosorio.hosocast.utils.Utils.java

/**
 * Shows an "Oops" error dialog with a text provided by a resource ID
 *///from   w w  w.jav a 2s .c om
public static void showOopsDialog(Context context, int resourceId) {
    new AlertDialog.Builder(context).setTitle(R.string.oops).setMessage(context.getString(resourceId))
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            })
            //.setIcon(R.drawable.ic_action_alerts_and_states_warning)
            .setIcon(R.drawable.ic_action_warning).create().show();
}

From source file:com.firefly.sample.castcompanionlibrary.utils.Utils.java

/**
 * A utility method to show a simple error dialog.
 *
 * @param context/*from  w ww . ja  v a2 s. c o  m*/
 * @param message The message to be shown in the dialog
 */
public static final void showErrorDialog(Context context, String message) {
    new AlertDialog.Builder(context).setTitle(R.string.error).setMessage(message)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create().show();
}

From source file:com.jerrellmardis.amphitheatre.util.Utils.java

/**
 * Shows an error dialog with a given text message.
 *
 * @param context/*from w w  w  .  j  a  v  a 2 s  .co m*/
 * @param errorString
 */
public static final void showErrorDialog(Context context, String errorString) {
    new AlertDialog.Builder(context).setTitle(R.string.error).setMessage(errorString)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create().show();
}

From source file:Main.java

/**
 * Show dialog and give 2 options: go to settings or leave the app
 *
 * @param activity the activity//from ww w .j  a v a  2s.c  o  m
 */
private static void showDialog(final Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setTitle("Bluetooth is turned off");
    builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON");
    builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
            activity.startActivity(setnfc);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            activity.finish();
        }
    });
    builder.show();
}

From source file:Main.java

public static void showGPSSettings(final Activity activity) {
    // check for internet connection
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
    alertDialog.setTitle("GPS adapter disabled");
    alertDialog.setMessage("GPS is not enabled. Please enable GPS");
    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
        }//from  w ww.  j a va  2  s. c o  m
    });
    // Setting Negative "NO" Button
    alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    // Showing Alert Message
    alertDialog.show();
}

From source file:Main.java

public static void alertTurnOnGPS(final Context mContext) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage("Do you want to enable GPS?").setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    mContext.startActivity(
                            new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }//from   w  w  w . j  ava 2s .  c om
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    dialog.cancel();
                }
            });
    final AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.mb.android.playbackmediator.utils.Utils.java

/**
 * A utility method to show a simple error dialog.
 *
 * @param context//from w  ww  . ja  v  a  2 s.c o  m
 * @param message The message to be shown in the dialog
 */
public static final void showErrorDialog(Context context, String message) {
    new AlertDialog.Builder(context).setTitle(R.string.error).setMessage(message)
            .setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create().show();
}

From source file:com.evozi.droidsniff.helper.DialogHelper.java

public static void installBusyBox(Activity context) {
    DialogHelper.context = context;/*from   w  w  w .  ja 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();
}