List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:devza.app.android.droidnetkey.FirewallAction.java
@Override protected void onPostExecute(Integer result) { /*INVALID_CREDENTIALS = -1; TIMED_OUT = -2;/*from w w w . ja va2s . c o m*/ GENERAL_ERROR = -3;*/ if (!refresh) { d.dismiss(); if (result < 0) { AlertDialog error = new AlertDialog.Builder(this.context).create(); error.setTitle("Error"); error.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int id) { d.cancel(); } }); String msg; switch (result) { case INVALID_CREDENTIALS: msg = "Invalid Username or Password"; break; case TIMED_OUT: msg = "Connection Timed Out. Is your device connected to the internet?"; break; case UNKNOWN_HOST: msg = "Could not connect. Is your device connected to the internet?"; break; case GENERAL_ERROR: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; default: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; } error.setMessage(msg); error.show(); } else { if (result == CONNECTED) { Intent usage = new Intent(this.context, UsageActivity.class); this.context.startActivity(usage); this.s.showNotification(true); this.s.startTimer(); } else { Intent main = new Intent(this.context, MainActivity.class); this.context.startActivity(main); this.s.showNotification(false); } } } }
From source file:com.app.swaedes.swaedes.MapPage.java
public void sitesPositionsFetchAlert() { AlertDialog.Builder localBuilder = new AlertDialog.Builder(MapPage.this); localBuilder.setMessage("Get location of other sites? (if no only current location will be displayed)") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramDialogInterface, int paramInt) { MapPage.this.getJsonMarkers(); }/*from www . ja va2 s . c om*/ }); localBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramDialogInterface, int paramInt) { paramDialogInterface.cancel(); } }); localBuilder.create().show(); }
From source file:com.application.treasurehunt.ScanQRCodeActivity.java
private void checkLocationServices() { //http://stackoverflow.com/questions/10311834/android-dev-how-to-check-if-location-services-are-enabled if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mAlertForNoLocationServices = new Builder(ScanQRCodeActivity.this); mAlertForNoLocationServices.setTitle("Location Services"); mAlertForNoLocationServices/*from w w w . ja va2 s . co m*/ .setMessage("Location services are not turned on. Turn on to track your treasure hunt."); mAlertForNoLocationServices.setCancelable(false); mAlertForNoLocationServices.setNegativeButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); mAlertForNoLocationServices.create(); mAlertForNoLocationServices.show(); } mLocationServicesChecked = true; }
From source file:com.ferid.app.frequentcontacts.MainActivity.java
/** * Adds a new contact to the application list.<br /> * Contacts are selected from the phone's contats' list. *///from w ww . j a v a 2 s. c o m private void addNewContact() { if (contactsList != null) { if (contactsList.size() < getResources().getInteger(R.integer.maxContactSize)) { Intent intent = new Intent(context, SelectNumberActivity.class); startActivityForResult(intent, SELECT_NUMBER); overridePendingTransition(R.anim.move_in_from_bottom, R.anim.stand_still); } else { //alert final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(context.getString(R.string.maxContactsNumber)); builder.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } } }
From source file:com.njlabs.amrita.aid.landing.Landing.java
public void checkForUpdates() { OkHttpClient client = new OkHttpClient.Builder().followRedirects(true).followSslRedirects(true).build(); Request.Builder request = new Request.Builder().url("https://api.codezero.xyz/aid/latest"); client.newCall(request.build()).enqueue(new Callback() { @Override//w w w. ja va 2s . c o m public void onFailure(Call call, IOException e) { Ln.e(e); } @Override public void onResponse(Call call, final Response rawResponse) throws IOException { final String responseString = rawResponse.body().string(); ((Activity) baseContext).runOnUiThread(new Runnable() { @Override public void run() { JSONObject response; try { response = new JSONObject(responseString); String status = ""; status = response.getString("status"); if (status.equals("ok")) { Double Latest = 0.0; String Description = null; try { Latest = response.getDouble("version"); Description = response.getString("description"); } catch (JSONException e) { FirebaseCrash.report(e); } if (Latest > BuildConfig.VERSION_CODE) { AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(Landing.this); LayoutInflater factory = LayoutInflater.from(Landing.this); final View changelogView = factory.inflate(R.layout.webview_dialog, null); LinearLayout WebViewDialogLayout = (LinearLayout) changelogView .findViewById(R.id.WebViewDialogLayout); WebViewDialogLayout.setPadding(5, 5, 5, 5); WebView changelogWebView = (WebView) changelogView .findViewById(R.id.LicensesView); changelogWebView.loadData(String.format("%s", Description), "text/html", "utf-8"); changelogWebView.setPadding(5, 5, 5, 5); changelogWebView.setBackgroundColor(0); changelogWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); changelogWebView.setLongClickable(false); updateDialogBuilder.setView(changelogView).setCancelable(true) .setCancelable(false) .setNegativeButton("Dismiss", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .setPositiveButton("Update Now", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri .parse("market://details?id=com.njlabs.amrita.aid"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); } }); AlertDialog alert = updateDialogBuilder.create(); alert.setTitle("Update Available"); alert.setIcon(R.mipmap.ic_launcher); alert.show(); } } } catch (Exception e) { Ln.e(e); } } }); } }); }
From source file:com.ardnezar.lookapp.ConnectActivity.java
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; }/*from w ww . ja v a2s . c o m*/ new AlertDialog.Builder(this).setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)).setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create().show(); return false; }
From source file:com.bringcommunications.etherpay.SendActivity.java
private void dsp_txid_and_exit() { /*//from w ww .j a v a 2 s.c om TextView txid_view = (TextView) findViewById(R.id.txid); txid_view.setText(txid); if (auto_pay.equals("true")) { String msg = txid.isEmpty() ? "transaction failed" : "your transaction was sent successfully"; Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); NavUtils.navigateUpFromSameTask(context); this.finish(); } else */ { AlertDialog.Builder builder = new AlertDialog.Builder(this); String title = txid.isEmpty() ? "Error" : "Transaction Sent"; String msg = txid.isEmpty() ? "An error occurred while attempting this transaction -- press OK to continue" : "your transaction was sent successfully -- press OK to continue"; builder.setTitle(title); builder.setMessage(msg); builder.setCancelable(true); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); NavUtils.navigateUpFromSameTask(context); context.finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.brq.wallet.activity.modern.AddressBookFragment.java
private void doDeleteEntry() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.delete_address_confirmation).setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); _mbwManager.getMetadataStorage().deleteAddressMetadata(mSelectedAddress); finishActionMode();/* www .j a v a2 s . c o m*/ _mbwManager.getEventBus().post(new AddressBookChanged()); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finishActionMode(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:org.webpki.mobile.android.proxy.BaseProxyActivity.java
public void showAlert(String message) { AlertDialog.Builder alert_dialog = new AlertDialog.Builder(this).setMessage(message).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Close the dialog box and do nothing dialog.cancel(); }/* w ww . j av a2 s . c om*/ }); // Create and show alert dialog alert_dialog.create().show(); }
From source file:es.uniovi.imovil.fcrtrainer.BaseExerciseFragment.java
private void showEndGameDialog() { String message = gameOverMessage(); Builder alert = new AlertDialog.Builder(getActivity()).setTitle(getResources().getString(R.string.end_game)) .setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override//from www . j ava 2 s . c om public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alert.show(); }