List of usage examples for android.app AlertDialog show
public void show()
From source file:com.zsxj.pda.ui.client.LoginActivity.java
private void showUpdateInfo(int type, final int method, final String url, final String ver, final long size, String msg) {/*from w w w . j a va 2 s . c o m*/ if (0 == type) { // No update return; } else if (1 == type) { // Option update new AlertDialog.Builder(LoginActivity.this).setTitle("???").setMessage(msg) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { download(url); } }).setNegativeButton("??", null).show(); } else if (2 == type) { // Force update final AlertDialog d = new AlertDialog.Builder(LoginActivity.this).setTitle("???") .setMessage(msg).setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { download(url); finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).create(); d.show(); } }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
private void showAlertDialog(String alertMessage) { if (this.isFinishing()) return;/*from w ww.ja v a 2s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(OpenHABMainActivity.this); builder.setMessage(alertMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
/** * ??Alter/* ww w. ja v a2 s. co m*/ * * @param message */ public void showAndroidAlert(final String title, final String message) { Runnable showAlert = new Runnable() { public void run() { final AlertDialog alert = new AlertDialog.Builder(LGameAndroid2DActivity.this).create(); alert.setTitle(title); alert.setMessage(message); alert.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert.dismiss(); } }); alert.show(); } }; runOnUiThread(showAlert); }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
private void showCertificateDialog(final int decisionId, String certMessage) { if (this.isFinishing()) return;/* w w w. j av a2 s . com*/ AlertDialog.Builder builder = new AlertDialog.Builder(OpenHABMainActivity.this); builder.setMessage(certMessage).setTitle(R.string.mtm_accept_cert); builder.setPositiveButton(R.string.mtm_decision_always, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Log.d(TAG, "User decided to always accept unknown certificate"); // MemorizingTrustManager.interactResult(decisionId, MTMDecision.DECISION_ALWAYS); sendMTMDecision(decisionId, MTMDecision.DECISION_ALWAYS); } }); builder.setNeutralButton(R.string.mtm_decision_once, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Log.d(TAG, "User decided to accept unknown certificate once"); // MemorizingTrustManager.interactResult(decisionId, MTMDecision.DECISION_ONCE); sendMTMDecision(decisionId, MTMDecision.DECISION_ONCE); } }); builder.setNegativeButton(R.string.mtm_decision_abort, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Log.d(TAG, "User decided to abort unknown certificate"); // MemorizingTrustManager.interactResult(decisionId, MTMDecision.DECISION_ABORT); sendMTMDecision(decisionId, MTMDecision.DECISION_ABORT); } }); AlertDialog certAlert = builder.create(); certAlert.show(); }
From source file:fm.smart.r1.activity.ItemActivity.java
public void addToList(final String item_id) { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Adding item to study list ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add = new Thread() { public void run() { ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, item_id, ItemActivity.this); myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(ItemActivity.add_item_result.getTitle()); dialog.setMessage(ItemActivity.add_item_result.getMessage()); ItemActivity.add_item_result = null; dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/*from w w w. ja v a2 s . com*/ }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add.start(); }
From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_view_as_grid) { Intent i = new Intent(POIMapActivity.this, POIGridActivity.class); i.putExtra("playOn", mActionPlay); i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); // finish(); overridePendingTransition(0, 0); startActivityForResult(i, 1);/*from ww w . ja v a2 s . c om*/ overridePendingTransition(0, 0); } else if (id == R.id.action_directions) { if (mActionDirections == 1) { // cancel directions action item.setIcon(R.drawable.ic_action_directions); mActionDirections = 0; tvMapDirectionsInfo.setVisibility(View.INVISIBLE); if (mRoute != null) { mRoute.remove(); } } else if (mActionDirections == 0) { // set directions action on item.setIcon(R.drawable.ic_action_directions_pressed); mActionDirections = 1; gmm.handleMapWarningMessages(POIMapActivity.this, tvMapMessage); if (gmm.myLocationEnabled && gmm.internetEnabled) { Toast.makeText(POIMapActivity.this, POIMapActivity.this.getResources().getString(R.string.tap_route_destination), Toast.LENGTH_SHORT).show(); } else { tvMapMessage.setBackgroundColor( POIMapActivity.this.getResources().getColor(R.color.red_transparent)); item.setIcon(R.drawable.ic_action_directions); mActionDirections = 0; tvMapDirectionsInfo.setVisibility(View.INVISIBLE); } } else { // mActionDirections == 3 item.setIcon(R.drawable.ic_action_directions); mActionDirections = 0; tvMapDirectionsInfo.setVisibility(View.INVISIBLE); if (mRoute != null) { mRoute.remove(); } } } else if (id == R.id.action_play) { if (mActionPlay) { // cancel play mode gmm.addAllMarkers(POIMapActivity.this); item.setIcon(R.drawable.ic_action_play); mActionPlay = false; miDirections.setIcon(R.drawable.ic_action_directions); mActionDirections = 0; tvMapDirectionsInfo.setVisibility(View.INVISIBLE); if (mRoute != null) { mRoute.remove(); } } else { gmm.addPlayMarkers(POIMapActivity.this); item.setIcon(R.drawable.ic_action_pause_red); if (gmm.activePOIMarker != null) { drawUserDestRoute(gmm.activePOIMarker.getPosition()); } mActionPlay = true; } } else if (id == R.id.action_google_map_type) { // get google map type names String[] googleMapTypeNames = getResources().getStringArray(R.array.google_map_type_names); // creating and Building the Dialog AlertDialog.Builder builderMapType = new AlertDialog.Builder(this); builderMapType.setTitle(getResources().getString(R.string.action_google_map_type)); builderMapType.setSingleChoiceItems(googleMapTypeNames, selectedMapType, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item != selectedMapType) { switchGoogleMapType(item); // save selected type in settings SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(POIMapActivity.this); SharedPreferences.Editor editor = preferences.edit(); editor.putString("googleMapType", String.valueOf(item)); editor.commit(); } mapTypeDialog.dismiss(); } }); mapTypeDialog = builderMapType.create(); mapTypeDialog.show(); } else if (id == R.id.action_legal_notices) { String licenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext()); AlertDialog.Builder licenseDialog = new AlertDialog.Builder(POIMapActivity.this); licenseDialog.setTitle(getString(R.string.action_legal_notices)); licenseDialog.setMessage(licenseInfo); licenseDialog.show(); } else if (id == R.id.action_scan_qr_code) { handleQRcodeScanRequest(); } else if (id == R.id.action_about) { String about = getString(R.string.about_application); AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(POIMapActivity.this).create(); alertDialog.setTitle(getString(R.string.action_about)); alertDialog.setMessage(Html.fromHtml(about)); alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:bikebadger.RideFragment.java
public void onInit(int initStatus) { // assert (false); //check for successful instantiation if (initStatus == TextToSpeech.SUCCESS) { //if(RideManager.mTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE) // RideManager.mTTS.setLanguage(Locale.US); } else if (initStatus == TextToSpeech.ERROR) { Toast.makeText(mRideManager.mAppContext, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show(); AlertDialog ad = new AlertDialog.Builder(getActivity()).create(); ad.setCancelable(false);/* w w w . j a va2s.c o m*/ ad.setTitle("Text To Speech Engine Not Found"); ad.setMessage( "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings."); ad.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); } }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
public void showTtsWarningIfShould() { boolean shouldShow = prefAdapter.getTtsShowDialog(); if (shouldShow) { // So we don't display this dialog again and bother the user prefAdapter.setTtsShowDialog(false); // Then display a dialog informing them of TTS AlertDialog dialog = new Builder(this).setTitle(R.string.main_tts_warning_title) .setMessage(R.string.main_tts_warning_text) .setPositiveButton(R.string.dialog_ok, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do nothing, just dismiss }/* w ww . j a v a 2s.c om*/ }).create(); dialog.show(); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
@Override public void urlConnectionDidReceiveResponse(HttpResponse httpResponse) { int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != Constants.HTTP_SUCCESS) { loadingPanelProgress.dismiss();//from www.ja v a 2 s . c o m if (statusCode == ControllerException.UNAUTHORIZED) { LoginDialog loginDialog = new LoginDialog(this); loginDialog.setOnClickListener(loginDialog.new OnloginClickListener() { @Override public void onClick(View v) { super.onClick(v); requestPanelList(); checkAuthentication(); requestAccess(); } }); } else { // The following code customizes the dialog, because the finish method should do after dialog show and click ok. AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Panel List Not Found"); alertDialog.setMessage(ControllerException.exceptionMessageOfCode(statusCode)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); } } }
From source file:com.teleca.jamendo.activity.PlayerActivity.java
public void downloadOnClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(PlayerActivity.this).setTitle(R.string.download_track_q) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { JamendoApplication.getInstance().getDownloadManager() .download(getPlayerEngine().getPlaylist().getSelectedTrack()); }//w ww. ja v a 2s. c o m }).setNegativeButton(R.string.cancel, null).create(); alertDialog.show(); mSlidingDrawer.animateClose(); }