List of usage examples for android.app AlertDialog show
public void show()
From source file:edu.cwru.apo.Directory.java
public void onClick(View v) { switch (v.getId()) { case R.id.btnCall: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + lastPhone)); startActivity(intent);/*from www .ja va 2 s . c o m*/ break; case R.id.btnText: startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", lastPhone, null))); break; default: String text = ((TextView) v).getText().toString(); int start = text.lastIndexOf('['); int end = text.lastIndexOf(']'); String caseID = text.substring(start + 1, end); Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, "_id = ?", new String[] { caseID }, null, null, null); if (results.getCount() != 1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Error Loading Phone Number").setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { results.moveToFirst(); phoneDialog = new Dialog(this); phoneDialog.setContentView(R.layout.phone_dialog); phoneDialog.setTitle(results.getString(0) + " " + results.getString(1)); TextView phoneText = (TextView) phoneDialog.findViewById((R.id.phoneText)); String phoneNumber = removeNonDigits(results.getString(3)); if (phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null")) { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(false); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(false); phoneNumber = "not available"; } else { ((Button) phoneDialog.findViewById(R.id.btnCall)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnText)).setEnabled(true); ((Button) phoneDialog.findViewById(R.id.btnCall)).setOnClickListener(this); ((Button) phoneDialog.findViewById(R.id.btnText)).setOnClickListener(this); } lastPhone = phoneNumber; phoneText.setText("Phone Number: " + lastPhone); phoneDialog.show(); } break; } }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
public void notififyGuestUsedKey(final String guestUser, final String guestService) { AlertDialog.Builder builder = new AlertDialog.Builder(LockActivity.this); builder.setInverseBackgroundForced(true); builder.setMessage("Remote key used by " + guestUser + "!").setCancelable(true).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();/* w w w. j a v a 2 s . c om*/ } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.app.sniffy.MainActivity.java
public void showTerms() { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View dialoglayout = inflater.inflate(R.layout.terms, null); WebView webView = (WebView) dialoglayout.findViewById(R.id.termsView); webView.loadUrl("file:///android_asset/license.html"); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Terms & Conditions"); builder.setView(dialoglayout).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { CheckBox checkBox = (CheckBox) dialoglayout.findViewById(R.id.checkBox); if (checkBox.isChecked()) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("userconsent", true); editor.commit(); try { new GetKey(context).execute( new URI(Utils.getConfigProperty(getResources(), "generate-key") + mDeviceId + Utils.getConfigProperty(getResources(), "securekey"))); } catch (URISyntaxException e1) { Log.d("main activity key generate", e1.toString()); }/*from w w w.jav a2 s. co m*/ } else { showTerms(); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
public void keyUpdate(final UserCredentials userCredentials) { AlertDialog.Builder builder = new AlertDialog.Builder(LockActivity.this); builder.setInverseBackgroundForced(true); builder.setMessage("Key updates have been made").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override//ww w. j av a 2s. c o m public void onClick(DialogInterface dialog, int which) { lock_fragment.setButtons(userCredentials); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.peterbaldwin.client.android.tinyurl.SendTinyUrlActivity.java
void handleError(Throwable throwable) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (throwable instanceof MalformedURLException) { builder.setMessage(R.string.message_invalid_url); } else {//from ww w . j a v a 2s. co m // TODO: User-friendly error messages builder.setMessage(String.valueOf(throwable)); } builder.setPositiveButton(R.string.button_ok, this); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:it.feio.android.omninotes.async.UpdaterTask.java
private void promptUpdate() { // Confirm dialog creation final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivityReference.get()); alertDialogBuilder.setCancelable(false).setMessage(R.string.new_update_available) .setPositiveButton(R.string.update, new DialogInterface.OnClickListener() { @Override/* ww w . j a v a2 s . co m*/ public void onClick(DialogInterface dialog, int id) { if (isGooglePlayAvailable()) { mActivityReference.get().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName))); } else { // MapBuilder.createEvent().build() returns a Map of event fields and values // that are set and sent with the hit. OmniNotes.getGaTracker().send(MapBuilder.createEvent("ui_action", // Event category (required) "button_press", // Event action (required) "Google Drive Update", // Event label null) // Event value .build()); mActivityReference.get().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.DRIVE_FOLDER_LAST_BUILD))); } dialog.dismiss(); } }).setNegativeButton(R.string.not_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.sixwonders.courtkiosk.CheckInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; view = LayoutInflater.from(this).inflate(R.layout.activity_check_in, null); btnInfoSubmit = (Button) view.findViewById(R.id.btnInfoSubmit); btnIdScan = (Button) view.findViewById(R.id.btnLicenseScan); btnIdScan.setOnClickListener(new View.OnClickListener() { @Override//from www. ja v a 2s . c o m public void onClick(View view) { callToScan(); } }); btnInfoSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); final View custom = LayoutInflater.from(activity) .inflate(R.layout.check_in_personal_info_alertdialog, null); builder.setTitle(R.string.userInformationInput).setPositiveButton(R.string.continueText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { //TODO call webservice to check for user EditText firstName = (EditText) custom.findViewById(R.id.etFirstName); EditText lastName = (EditText) custom.findViewById(R.id.etLastName); DatePicker dob = (DatePicker) custom.findViewById(R.id.dpDob); if (dob == null) { int i = 0; i++; i++; } int monthInt = dob.getMonth() + 1; String month = ""; if (monthInt < 10) { month += "0"; } month += monthInt; int dayInt = dob.getDayOfMonth(); String day = ""; if (dayInt < 10) { day += "0"; } day += dayInt; int yearInt = dob.getYear(); String year = ""; if (yearInt < 10) { year += "0"; } year += yearInt; String dobStr = month + "/" + day + "/" + year; ConnectionUtil connectionUtil = new ConnectionUtil(); connectionUtil.authCall(firstName.getText().toString(), lastName.getText().toString(), dobStr, (AsyncResponse) activity); } }); builder.setView(custom); datePicker = (DatePicker) custom.findViewById(R.id.dpDob); setUpDatePicker(); AlertDialog alert = builder.create(); alert.show(); } }); setContentView(view); }
From source file:com.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override/* w w w .j a va2s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:net.reichholf.dreamdroid.activities.TimerListActivity.java
/** * Confirmation dialog before timer deletion *//*from ww w.j av a 2s . com*/ private void deleteTimerConfirm() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(mTimer.getString(Timer.NAME)).setMessage(getText(R.string.delete_confirm)) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteTimer(mTimer); dialog.dismiss(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.rei.lolchat.ui.Login.java
/** * Create an about "BEEM" dialog.//from w w w.ja va 2 s . c o m */ private void createAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String versionname; try { PackageManager pm = getPackageManager(); PackageInfo pi = pm.getPackageInfo("com.rei.lolchat", 0); versionname = pi.versionName; } catch (PackageManager.NameNotFoundException e) { versionname = ""; } String title = getString(R.string.login_about_title, versionname); builder.setTitle(title).setMessage(R.string.login_about_msg).setCancelable(false); builder.setNeutralButton(R.string.login_about_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); AlertDialog aboutDialog = builder.create(); aboutDialog.show(); }