List of usage examples for android.app AlertDialog dismiss
@Override public void dismiss()
From source file:no.barentswatch.fiskinfo.MapActivity.java
public void showProximityAlertDialog(Context activityContext) { LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.dialog_proximity_alert, null); final AlertDialog builder = new AlertDialog.Builder(activityContext).create(); builder.setTitle(R.string.map_proximity_alert_title); builder.setView(view);// w w w. j a v a 2s. com Button goToMyPositionButton = (Button) view.findViewById(R.id.proximityAlertViewPositionButton); Button cancelProximityAlert = (Button) view.findViewById(R.id.proximityAlertCancelButton); builder.setView(view); goToMyPositionButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { builder.dismiss(); browser.loadUrl("javascript:zoomToUserPosition()"); } }); cancelProximityAlert.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: stop alert builder.dismiss(); } }); builder.show(); }
From source file:es.ugr.swad.swadroid.modules.downloads.DownloadsManager.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { Intent activity;/*from ww w . j ava2 s . c o m*/ switch (requestCode) { // After get the list of courses, a dialog is launched to choice the // course case Constants.DIRECTORY_TREE_REQUEST_CODE: tree = data.getStringExtra("tree"); if (!refresh) { setMainView(); } else { refresh = false; if (!noConnectionView) refresh(); else setMainView(); } break; case Constants.GETFILE_REQUEST_CODE: Log.d(TAG, "Correct get file"); //if the sd card is not busy, the file can be downloaded if (this.checkMediaAvailability() == 2) { Log.i(TAG, "External storage is available"); String url = data.getExtras().getString("link"); downloadFile(Constants.DIRECTORY_SWADROID, url, fileSize); //Toast.makeText(this, chosenNodeName +" "+ this.getResources().getString(R.string.notificationDownloadTitle) , Toast.LENGTH_LONG).show(); } else { //if the sd card is busy, it shows a alert dialog Log.i(TAG, "External storage is NOT available"); AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog; builder.setTitle(R.string.sdCardBusyTitle); builder.setMessage(R.string.sdCardBusy); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); } break; case Constants.GETMARKS_REQUEST_CODE: activity = new Intent(this, Marks.class); activity.putExtra("content", GetMarks.getMarks()); startActivityForResult(activity, Constants.MARKS_REQUEST_CODE); break; case Constants.GROUPS_REQUEST_CODE: groupsRequested = true; myGroups = getFilteredGroups(); //only groups where the user is enrolled. this.loadGroupsSpinner(myGroups); if (myGroups.size() == 0) requestDirectoryTree(); break; case Constants.GROUPTYPES_REQUEST_CODE: activity = new Intent(this, Groups.class); activity.putExtra("courseCode", Courses.getSelectedCourseCode()); startActivityForResult(activity, Constants.GROUPS_REQUEST_CODE); break; } } else { if (refresh) { refresh = false; } } }
From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java
/** * Display a dialog message TODO: make a fragment * * @param cName// w w w.j a va2s . c om * @param resId */ private void displayMessage(String cName, int resId) { AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.loc_overlap_title) .setMessage(getString(resId, cName)) .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.show(); dialog.setOwnerActivity(this); }
From source file:org.ohmage.triggers.types.location.LocTrigMapsActivity.java
/** * Display a dialog message TODO: make a fragment * //ww w. ja v a 2s .c o m * @param cName * @param resId */ private void displayMessage(String cName, int resId) { AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.loc_overlap_title) .setMessage(getString(resId, cName)) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.show(); dialog.setOwnerActivity(this); }
From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java
public void displayalertdialog(double latitude, double longitude, String address, int success) { final double lat = latitude; final double lng = longitude; if (success == 1) { final AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Congratulations!"); // Setting Dialog Message alertDialog.setMessage("Your parking spot has been blocked"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); AlertDialog alertDialog1 = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this) .create();// w w w .j a v a 2s.co m // Setting Dialog Title alertDialog1.setTitle("Do you want to get directions?"); alertDialog1.setButton2("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.e("GetIndividualParkingSpots", "Inside Yes"); Intent yesintent = new Intent(GetIndividualParkingSpotDetails.this, GoogleDirectionsActivity.class); yesintent.putExtra(GetParkingLots.LATITUDE, lat); yesintent.putExtra(GetParkingLots.LONGITUDE, lng); startActivity(yesintent); Log.e("GetIndividualParkingSpots", "After Calling Intent"); } }); alertDialog1.setButton3("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent nointent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(nointent); } }); alertDialog1.show(); } }); // Showing Alert Message alertDialog.show(); if (chk_default.isChecked()) { Log.i("GetIndividualParkingSpotDetails", "Inside Checkbox if "); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till long " + toTime); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till DateTime" + DateTimeHelpers.convertToTimeFromLong(toTime)); Log.i("GetIndividualParkingSpotDetails", "Inside if checkbox address" + address); scheduleNotification(getNotification( "You parked the car in" + address + "Your parking spot id is " + theParkingSpotName)); } } else { AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Sorry!"); // Setting Dialog Message alertDialog.setMessage("There was a problem processing your request"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent intent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(intent); } }); // Showing Alert Message alertDialog.show(); } }
From source file:org.notfunnynerd.opencoinmap.MapActivity.java
private void showRadiusDialog() { final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle(R.string.near_you); LayoutInflater inflater = getLayoutInflater(); final View layout = inflater.inflate(R.layout.radius_dialog, null); dialogBuilder.setView(layout);/*from w ww .j a v a2s.co m*/ final AlertDialog dialog = dialogBuilder.create(); dialog.show(); final TextView radiusValue = (TextView) layout.findViewById(R.id.radiusValue); ListView listView = (ListView) layout.findViewById(R.id.listPlaces); final ArrayList<Place> localPlaces = new ArrayList<Place>(); final ArrayAdapter<Place> adapter = new ArrayAdapter<Place>(this, android.R.layout.simple_list_item_1, localPlaces); listView.setAdapter(adapter); final SeekBar seekRadius = (SeekBar) layout.findViewById(R.id.seekRadius); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { dialog.dismiss(); Marker marker = getMarkerFromPlace(localPlaces.get(position)); mMap.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition())); marker.showInfoWindow(); } }); seekRadius.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { int current = 0; @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { current = progress; radiusValue.setText("" + progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { localPlaces.clear(); for (Place place : getPlacesWithinRadius(current)) { localPlaces.add(place); } adapter.notifyDataSetChanged(); } }); ((Button) layout.findViewById(R.id.okButton)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
From source file:edu.asu.bsse.vtanders.finalproject.MainActivity.java
License:asdf
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_config) { AlertDialog.Builder connInfoDialogBuilder = new AlertDialog.Builder(this); connInfoDialogBuilder.setTitle("Server Information"); final View view = getLayoutInflater().inflate(R.layout.server_config, null); connInfoDialogBuilder.setView(view); final AlertDialog connInfoDialog = connInfoDialogBuilder.create(); connInfoDialog.show();/* w w w .j a va2s . c o m*/ Button apply = (Button) view.findViewById(R.id.apply_settings_button); apply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText hostET = (EditText) view.findViewById(R.id.host_content); String host = hostET.getText().toString(); EditText portET = (EditText) view.findViewById(R.id.port_content); int port = Integer.valueOf(portET.getText().toString()); EditText nickET = (EditText) view.findViewById(R.id.nickname_content); String nick = nickET.getText().toString(); Log.d("ASDF", host + " " + port + " " + nick); new SetupConnectionTask(host, port, nick).execute(); connInfoDialog.dismiss(); } }); return true; } return super.onOptionsItemSelected(item); }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpAirPlane.java
private void provideOrderPrice() { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); // ...Irrelevant code for customizing the buttons and title dialogBuilder.setTitle(getString(R.string.order_change_fee)); LayoutInflater inflater = getActivity().getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_enter_order_price_layout, null); dialogBuilder.setView(dialogView);//from w w w .j a v a 2 s . c o m TextView content = (TextView) dialogView.findViewById(R.id.txt_msg); final EditText enter = (EditText) dialogView.findViewById(R.id.editText_password); enter.setText(""); final EditText tip = (EditText) dialogView.findViewById(R.id.editText_tip); tip.setText(""); Button sure = (Button) dialogView.findViewById(R.id.sure_action); Button cancel = (Button) dialogView.findViewById(R.id.cancel_action); final AlertDialog alertDialog = dialogBuilder.create(); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); } }); sure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { parserAddressToGPS(); createTaxiOrder("" + option, enter.getText().toString(), tip.getText().toString()); if (alertDialog != null) { alertDialog.dismiss(); } } }); alertDialog.show(); }
From source file:com.df.app.carCheck.VehicleInfoLayout.java
/** * edit/*from w w w .j a va 2s.co m*/ */ private void showListDialog(int titleId, ArrayAdapter<String> adapter, final Handler handler) { View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create(); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); final ListView listView = new ListView(view1.getContext()); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { handler.sendEmptyMessage(i); dialog.dismiss(); } }); contentArea.addView(listView); setTextView(view1, R.id.title, getResources().getString(titleId)); dialog.show(); }
From source file:com.swetha.easypark.GetParkingLots.java
@Override protected void onCreate(Bundle savedInstanceState) { if (!isGooglePlayServicesAvailable()) { finish();/* w ww . j a v a 2s. com*/ } super.onCreate(savedInstanceState); setContentView(R.layout.getparkinglots); SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); googleMap = supportMapFragment.getMap(); googleMap.setMyLocationEnabled(true); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (gps_enabled) { Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, true); if (provider != null && !provider.equals("")) { locationManager.requestLocationUpdates(provider, 500, 1, GetParkingLots.this); // Get the location from the given provider location = locationManager.getLastKnownLocation(provider); } } Log.i("GetParkingLots", "Value of network_enabled and location" + network_enabled + location); if (location == null && network_enabled) { location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 1, GetParkingLots.this); } if (location == null && !network_enabled && !gps_enabled) { Toast.makeText(getBaseContext(), "Enable your location services", Toast.LENGTH_LONG).show(); } if (location != null) onLocationChanged(location); else { Toast.makeText(getBaseContext(), "Location can't be retrieved", Toast.LENGTH_SHORT).show(); } tv_fromTime = (TextView) findViewById(R.id.tv_fromTime); fromTimeString = Constants.dtf.format(new Date()).toString(); tv_fromTime.setText(fromTimeString); long lval = DateTimeHelpers.convertToLongFromTime(Constants.dtf.format(new Date()).toString()); Log.i("GetParkingLots", "The value of current time:" + Constants.dtf.format(new Date()).toString() + "in long is" + lval); Log.i("GetParkingLots", "The value of current time:" + lval + "in long is" + DateTimeHelpers.convertToTimeFromLong(lval)); tv_toTime = (TextView) findViewById(R.id.tv_ToTime); // Parsing the date toTimeString = Constants.dtf.format(new Date()).toString(); tv_toTime.setText(toTimeString); btnFromTime = (Button) findViewById(R.id.fromButton); btnFromTime.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(GetParkingLots.this); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) getLayoutInflater() .inflate(R.layout.date_time_dialog, null); // Grab widget instance mDateTimePicker = (DateTimePicker) mDateTimeDialogView.findViewById(R.id.DateTimePicker); mDateTimePicker.setDateChangedListener(GetParkingLots.this); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new OnClickListener() { Calendar cal; @SuppressWarnings("deprecation") public void onClick(View v) { mDateTimePicker.clearFocus(); try { cal = new GregorianCalendar(mDateTimePicker.getYear(), Integer.parseInt(mDateTimePicker.getMonth()), mDateTimePicker.getDay(), mDateTimePicker.getHour(), mDateTimePicker.getMinute()); fromTimeString = DateTimeHelpers.dtf.format(cal.getTime()); tv_fromTime.setText(fromTimeString); } catch (Exception e) { final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this) .create(); alertDialog.setMessage("Enter a valid date"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); } mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); btnToTime = (Button) findViewById(R.id.toButton); btnToTime.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(GetParkingLots.this); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) getLayoutInflater() .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); mDateTimePicker.setDateChangedListener(GetParkingLots.this); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new OnClickListener() { Calendar cal; @SuppressWarnings("deprecation") public void onClick(View v) { mDateTimePicker.clearFocus(); Log.i("toButton", "Value of ToString before cal" + toTimeString); try { cal = new GregorianCalendar(mDateTimePicker.getYear(), Integer.parseInt(mDateTimePicker.getMonth()), mDateTimePicker.getDay(), mDateTimePicker.getHour(), mDateTimePicker.getMinute()); toTimeString = DateTimeHelpers.dtf.format(cal.getTime()); Log.i("toButton", "Value of ToString before cal" + toTimeString); tv_toTime.setText(toTimeString); } catch (Exception e) // fixing the bug where the user doesnt enter anything in the textbox { final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this) .create(); alertDialog.setMessage("Enter a valid date"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); } //dateTimeTo = new DateTime(mDateTimePicker.getYear(), Integer.parseInt(mDateTimePicker.getMonth()) , mDateTimePicker.getDay(), mDateTimePicker.getHour(), mDateTimePicker.getMinute()); ; mDateTimeDialog.dismiss(); } }); ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); btnGetParkingLots = (Button) findViewById(R.id.getNearByParkingLotsButton); btnGetParkingLots.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") public void onClick(View v) { et_search = (EditText) findViewById(R.id.edittextsearch); rg = (RadioGroup) findViewById(R.id.rg); checkedRbId = rg.getCheckedRadioButtonId(); Log.i("LOG_TAG: GetParkingLots", "checked radiobutton id is" + checkedRbId); if (checkedRbId == R.id.rbradius) { isRadiusIndicator = true; radius = et_search.getText().toString(); } else { isRadiusIndicator = false; zipcode = et_search.getText().toString(); } final Intent intent = new Intent(GetParkingLots.this, DisplayVacantParkingLots.class); Log.i(TAG, "Inside getNearByParkingLots"); Log.i(TAG, "Value of fromString" + fromTimeString); long lFromVal = DateTimeHelpers.convertToLongFromTime(fromTimeString); Log.i(TAG, "Value of ToString" + toTimeString); long lToVal = DateTimeHelpers.convertToLongFromTime(toTimeString); if ((lToVal - lFromVal) < Constants.thrityMinInMilliSeconds) { final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create(); alertDialog.setMessage("You have to park the car for at least 30 min"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); } else { intent.putExtra(LATITUDE, latitude); intent.putExtra(LONGITUDE, longitude); intent.putExtra(FROMTIME, lFromVal); intent.putExtra(TOTIME, lToVal); intent.putExtra(RadiusOrZIPCODE, isRadiusIndicator); if (isRadiusIndicator) try { intent.putExtra(RADIUS, Double.parseDouble(radius)); startActivity(intent); } catch (Exception e) { final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create(); alertDialog.setMessage("Enter valid radius"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); } else { try { intent.putExtra(ZIPCODE, Long.parseLong(zipcode)); startActivity(intent); } catch (Exception e) { final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create(); alertDialog.setMessage("Enter a valid Zip code"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); } } } } }); }