Example usage for android.app AlertDialog.Builder create

List of usage examples for android.app AlertDialog.Builder create

Introduction

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

Prototype

public void create() 

Source Link

Document

Forces immediate creation of the dialog.

Usage

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

public void showShareDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(ViewRedditActivity.this);
    builder.setMessage("Share Url").setNegativeButton("Content", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            shareText(getIntent().getStringExtra(WidgetProvider.ITEM_URL));
        }//from  ww w . j  av a  2 s  . co  m
    }).setPositiveButton("Reddit Page", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            shareText("http://reddit.com" + getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK));
        }
    });
    // Create the AlertDialog
    builder.create().show();
}

From source file:fr.gotorennes.AbstractMapActivity.java

protected void showError(String message, final boolean finish) {
    AlertDialog.Builder build = new AlertDialog.Builder(this);
    build.setMessage(message);// ww  w  .j a va  2s .  c  o m
    build.setPositiveButton("Ok", new android.content.DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (finish)
                finish();
        }

    });
    build.create().show();
}

From source file:com.fabernovel.alertevoirie.NewsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.report_detail_new_report_ok).setCancelable(false).setPositiveButton("Ok",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        NewsActivity.this.finish();
                        // Toast.makeText(this, R.string.report_detail_new_report_ok, Toast.LENGTH_SHORT).show();
                        NewsActivity.this.overridePendingTransition(android.R.anim.fade_in,
                                android.R.anim.fade_out);
                    }/*from www  .  j  a v  a 2  s .c o m*/
                });
        AlertDialog alert = builder.create();
        alert.show();

    }
}

From source file:com.parking.billing.ParkingPayment.java

private Dialog createDialog(int titleId, int messageId) {
    String helpUrl = replaceLanguageAndRegion(getString(R.string.help_url));
    if (BillingConstants.DEBUG) {
        Log.i(TAG, helpUrl);//from  w w w.j a v a 2 s .c om
    }
    final Uri helpUri = Uri.parse(helpUrl);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(titleId).setIcon(android.R.drawable.stat_sys_warning).setMessage(messageId)
            .setCancelable(false).setPositiveButton(android.R.string.ok, null)
            .setNegativeButton(R.string.learn_more, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, helpUri);
                    startActivity(intent);
                }
            });
    return builder.create();
}

From source file:com.iss.android.wearable.datalayer.MainActivity.java

private void displaySWBatteryWarning() {
    // Display a cancelable warning that the HRM battery is running low.
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    String warning = "The Smartwatch battery charge is below 75%. Please charge it to ensure it lasts the night.";
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(100);/* www  .  jav  a 2 s .c om*/
    builder.setMessage(warning).setTitle(R.string.battery_warning_title).setCancelable(true)
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });

    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

public void showOpenDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(ViewRedditActivity.this);
    builder.setMessage("Open Url").setNegativeButton("Content", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            openUrlExternally(getIntent().getStringExtra(WidgetProvider.ITEM_URL));
        }//from  w  w w  .j av a2  s. c  o  m
    }).setPositiveButton("Reddit Page", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            openUrlExternally("http://reddit.com" + getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK));
        }
    });
    // Create the AlertDialog
    builder.create().show();
}

From source file:com.njlabs.amrita.aid.aums.AumsActivity.java

@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_aums, Color.parseColor("#e91e63"));

    rollNoEditText = (EditText) findViewById(R.id.roll_no);
    passwordEditText = (EditText) findViewById(R.id.pwd);

    List<String> campusDataSet = new LinkedList<>(Arrays.asList("Ettimadai", "Amritapuri", "Bangalore",
            "Mysore", "AIMS", "Business schools", "ASAS Kochi"));

    spinner = (MaterialSpinner) findViewById(R.id.spinner);
    spinner.setItems(campusDataSet);//from ww w. j  ava 2  s. co m

    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Amrita University does not provide an API for accessing AUMS data. "
            + "So, if any changes are made to the AUMS Website, please be patient while I try to catch up.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Got it !", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    hideSoftKeyboard();
                }
            });

    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alert.show();

    dialog = new ProgressDialog(baseContext);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setMessage("Authenticating your credentials ... ");

    aumsPreferences = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE);
    String rollNo = aumsPreferences.getString("RollNo", "");
    String encodedPassword = aumsPreferences.getString("Password", "");
    spinner.setSelectedIndex(aumsPreferences.getInt("server_ordinal", 0));

    aums = new Aums(baseContext);

    if (!rollNo.equals("")) {
        ((EditText) findViewById(R.id.roll_no)).setText(rollNo);
        aums.studentRollNo = rollNo;
        hideSoftKeyboard();
    }

    if (!encodedPassword.equals("")) {
        ((EditText) findViewById(R.id.pwd)).setText(Security.decrypt(encodedPassword, MainApplication.key));
        hideSoftKeyboard();
    }

}

From source file:it.mb.whatshare.Dialogs.java

/**
 * Shows a dialog containing the code received by goo.gl if any, or an error
 * message stating that the pairing operation failed.
 * /*w  ww .  ja v  a 2s  .  c  o  m*/
 * @param googl
 *            the pairing code retrieved by goo.gl
 * @param activity
 *            the caller activity
 */
public static void onObtainPairingCode(final String googl, final MainActivity activity) {
    new PatchedDialogFragment() {
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            AlertDialog.Builder builder = getBuilder(activity);
            if (googl != null) {
                View layout = View.inflate(getContext(), R.layout.pairing_code_dialog, null);
                TextView message = (TextView) layout.findViewById(R.id.pairingCode);
                Typeface typeFace = Typeface.createFromAsset(activity.getAssets(), CUSTOM_TYPEFACE_PATH);
                message.setTypeface(typeFace);
                message.setText(googl);
                builder.setView(layout);
            } else {
                builder.setMessage(getResources().getString(R.string.code_dialog_fail));
            }
            builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (googl != null) {
                        Resources res = getResources();
                        String howManyTotal = res.getQuantityString(R.plurals.added_device,
                                activity.getInboundDevicesCount(), activity.getInboundDevicesCount());
                        Toast.makeText(getActivity(), res.getString(R.string.device_paired, howManyTotal),
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
            return builder.create();
        }
    }.show(activity.getSupportFragmentManager(), "resultCode");
}

From source file:org.webpki.mobile.android.proxy.BaseProxyActivity.java

public void unconditionalAbort(final String message) {
    final BaseProxyActivity instance = this;
    AlertDialog.Builder alert_dialog = new AlertDialog.Builder(this).setMessage(message).setCancelable(false)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // The user decided that this is not what he/she wants...
                    dialog.cancel();//from w w w. j a v  a2  s. c  om
                    user_aborted = true;
                    abortTearDown();
                    if (abort_url == null) {
                        instance.finish();
                    } else {
                        launchBrowser(abort_url);
                    }
                }
            });
    // Create and show alert dialog
    alert_dialog.create().show();
}