Example usage for android.app AlertDialog setButton

List of usage examples for android.app AlertDialog setButton

Introduction

In this page you can find the example usage for android.app AlertDialog setButton.

Prototype

@Deprecated
public void setButton(CharSequence text, final OnClickListener listener) 

Source Link

Document

Set a listener to be invoked when button 1 of the dialog is pressed.

Usage

From source file:com.sck.maininterface.PaymentInfo.java

@SuppressWarnings("deprecation")
@Override/* w  ww  . j a v a 2  s.c  o  m*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_PAYMENT) {

        if (resultCode == Activity.RESULT_OK) {

            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);

            if (confirm != null) {

                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));

                    /*   Toast.makeText(
                             getApplicationContext(),
                             "Payment Confirmation info received from PayPal",
                             Toast.LENGTH_LONG).show();*/

                    AlertDialog ad = new AlertDialog.Builder(this).create();
                    ad.setCancelable(false); // This blocks the 'BACK' button  
                    ad.setMessage("Payment Confirmation info received from PayPal");
                    ad.setButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    ad.show();
                    //new updateExpiryDate().execute();
                    //paymentSuccess=true;
                    saveExpDate(renewedDate);

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        }

        else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        }

        else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    }

    // /

}

From source file:sssemil.com.hostsaway.ui.BlacklistFragment.java

/**
 * Add new entry based on input//  w  w  w . java  2s  .  c o m
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidHostname(input)) {
            ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:sssemil.com.hostsaway.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input/*from ww  w  . j  ava 2  s  .c  om*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:sssemil.com.hostsaway.ui.WhitelistFragment.java

/**
 * Add new entry based on input/*from  ww w  . ja  va  2  s.  co m*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidWhitelistHostname(input)) {
            ProviderHelper.insertWhitelistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:com.ceino.chaperonandroid.activities.LicenseActivity.java

public void showAlertDialog(Activity context, String title, String message, Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();

    // Setting Dialog Title
    alertDialog.setTitle(title);/*  ww  w  .ja  v a 2  s  .c  om*/

    // Setting Dialog Message
    alertDialog.setMessage(message);

    // Setting alert dialog icon
    alertDialog.setIcon((status) ? R.drawable.ic_launcher : R.drawable.ic_launcher);

    // Setting OK Button
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    // Showing Alert Message
    alertDialog.show();
}

From source file:com.aknowledge.v1.automation.RemoteActivity.java

public void showServerAlert() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Can't Connect to server!");
    alertDialog.setMessage("Check your server details under settings");
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }/*ww  w.  j  a  v a 2  s . co m*/
    });
    // Set the Icon for the Dialog
    alertDialog.show();

}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void alertdialog_canceljob() {

    String check = Query.jobQuery("clientcancel", job_id, 0, driver_id);
    if (check.equals("done")) {
        AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
        dcancelbuilder.setMessage("Job has been cancelled.\n");
        dcancelbuilder.setButton("Ok", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {

                Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
                startActivity(openStart);

            }//from w  w w .ja  va  2 s  . c o m
        });
        dcancelbuilder.show();
    } else {
        Toast.makeText(getBaseContext(), "Could not connect to server.\nPlease try again.", Toast.LENGTH_SHORT)
                .show();
    }

}

From source file:org.adawaycn.ui.RedirectionListFragment.java

/**
 * Add new entry based on input/*  w w  w  .  j  a  v  a  2  s  .  co m*/
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (org.adawaycn.util.RegexUtils.isValidHostname(hostname)) {
            if (org.adawaycn.util.RegexUtils.isValidIP(ip)) {
                org.adawaycn.provider.ProviderHelper.insertRedirectionListItem(mActivity, hostname, ip);
            } else {
                AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                alertDialog.setTitle(R.string.no_ip_title);
                alertDialog.setMessage(getString(R.string.no_ip));
                alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sum) {
                        dlg.dismiss();
                    }
                });
                alertDialog.show();
            }
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adaway.ui.RedirectionListFragment.java

/**
 * Add new entry based on input//from w  ww. j a v a2s . c  o m
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (RegexUtils.isValidHostname(hostname)) {
            if (RegexUtils.isValidIP(ip)) {
                ProviderHelper.insertRedirectionListItem(mActivity, hostname, ip);
            } else {
                AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                alertDialog.setTitle(R.string.no_ip_title);
                alertDialog.setMessage(getString(org.adaway.R.string.no_ip));
                alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sum) {
                        dlg.dismiss();
                    }
                });
                alertDialog.show();
            }
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void alertdialog_drivercancelintime() {
    AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
    dcancelbuilder.setMessage("Job has been cancelled.\nPlease look for another driver.");
    dcancelbuilder.setButton("Ok", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
            startActivity(openStart);//from  w  w w .  j ava 2s.c om

        }
    });
    dcancelbuilder.show();
}