List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.example.ogadrive.HomeActivity2.java
private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Your GPS seems to be disabled, do you want to enable it?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }// www . jav a 2 s . c o m }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:com.wirelessmoves.cl.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case RESET_COUNTER: NumberOfCellChanges = 0;//from w w w . j a v a2 s . c o m NumberOfLacChanges = 0; NumberOfSignalStrengthUpdates = 0; NumberOfUniqueCellChanges = 0; /* Initialize PreviousCells Array to a defined value */ for (int x = 0; x < PreviousCells.length; x++) PreviousCells[x] = 0; return true; case ABOUT: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "Cell Logger\r\n2012, Martin Sauter\r\n2014, rong zedong.\r\nhttp://www.wirelessmoves.com") .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; case TOGGLE_DEBUG: /* Toggle the debug behavior of the program when the user selects this menu item */ if (outputDebugInfo == false) { outputDebugInfo = true; } else { outputDebugInfo = false; } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.elekso.potfix.MainActivity.java
private void showNetDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("Internet will improve accuracy. Would you like to enable it?") .setCancelable(false).setPositiveButton("Enable Internet", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); startActivity(callGPSSettingIntent); }/*from w w w . ja v a 2 s. com*/ }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
From source file:com.cypress.cysmart.CommonFragments.CarouselFragment.java
void showWarningMessage() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); // set title/* w w w .j a va2 s . com*/ alertDialogBuilder.setTitle(R.string.alert_message_unknown_title); // set dialog message alertDialogBuilder.setMessage(R.string.alert_message_unkown).setCancelable(false) .setPositiveButton(R.string.alert_message_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { GattServicesFragment gattsericesfragment = new GattServicesFragment().create(); displayView(gattsericesfragment, getResources().getString(R.string.gatt_db)); } }).setNegativeButton(R.string.alert_message_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.google.android.apps.mytracks.TabManager.java
@Override public void onTabChanged(String tabId) { // Alert if nogago Maps isnt installed AlertDialog.Builder notInstalled = new AlertDialog.Builder(fragmentActivity); notInstalled.setMessage(R.string.maps_not_installed).setCancelable(false) .setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri.parse(Constants.MAPS_DOWNLOAD_URL); Intent showUri = new Intent(Intent.ACTION_VIEW, uri); fragmentActivity.startActivity(showUri); }/*from w w w . jav a2 s.c o m*/ }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); final AlertDialog alertnotInstalled = notInstalled.create(); // Alert if nogago Maps is installed AlertDialog.Builder builder = new AlertDialog.Builder(fragmentActivity); builder.setMessage(R.string.wanna_start_maps).setCancelable(false) .setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { if (isRecording()) { String nogagoPackage = "com.nogago.android.maps"; String mapActivity = ".activities.MapActivity"; Intent intent = new Intent(); intent.setComponent(new ComponentName(nogagoPackage, nogagoPackage + mapActivity)); fragmentActivity.startActivity(intent); } else { String trackPackage = "com.nogago.android.tracks"; String trackDetailActivity = ".TrackDetailActivity"; Intent tda = new Intent(); tda.setComponent( new ComponentName(trackPackage, trackPackage + trackDetailActivity)); tda.putExtra("clicked", true); fragmentActivity.startActivity(tda); } } catch (NullPointerException e) { alertnotInstalled.show(); } } }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); if (tabId.compareTo("mapFragment") == 0) { try { tabId = StatsFragment.STATS_FRAGMENT_TAG; // nogagoMaps aufrufen this.tabHost.setCurrentTab(1); try { if (isRecording()) { String nogagoPackage = "com.nogago.android.maps"; String mapActivity = ".activities.MapActivity"; Intent intent = new Intent(); intent.setComponent(new ComponentName(nogagoPackage, nogagoPackage + mapActivity)); fragmentActivity.startActivity(intent); } else { String trackPackage = "com.nogago.android.tracks"; String trackDetailActivity = ".TrackDetailActivity"; Intent tda = new Intent(); tda.setComponent(new ComponentName(trackPackage, trackPackage + trackDetailActivity)); tda.putExtra("clicked", true); fragmentActivity.startActivity(tda); } } catch (NullPointerException e) { alertnotInstalled.show(); } // alert.show(); // falls nicht installiert, fragen, ob installiert werden soll } catch (NullPointerException e) { alertnotInstalled.show(); } } TabInfo newTabInfo = tabs.get(tabId); if (lastTabInfo != newTabInfo) { FragmentTransaction fragmentTransaction = fragmentActivity.getSupportFragmentManager() .beginTransaction(); if (lastTabInfo != null) { if (lastTabInfo.fragment != null) { fragmentTransaction.detach(lastTabInfo.fragment); } } if (newTabInfo != null) { if (newTabInfo.fragment == null) { newTabInfo.fragment = Fragment.instantiate(fragmentActivity, newTabInfo.clss.getName(), newTabInfo.bundle); fragmentTransaction.add(containerId, newTabInfo.fragment, newTabInfo.tag); } else { fragmentTransaction.attach(newTabInfo.fragment); } } lastTabInfo = newTabInfo; fragmentTransaction.commit(); fragmentActivity.getSupportFragmentManager().executePendingTransactions(); } }
From source file:com.brq.wallet.lt.activity.sell.AdsFragment.java
private void confirmDeleteEntry() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this.getActivity()); // Set title//from w w w . j av a2 s. c o m alertDialogBuilder.setTitle(R.string.lt_confirm_delete_sell_order_title); // Set dialog message alertDialogBuilder.setMessage(R.string.lt_confirm_delete_sell_order_message); // Yes action alertDialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); _mbwManager.runPinProtectedFunction(getActivity(), pinProtectedDeleteEntry); finishActionMode(); } }); // No action alertDialogBuilder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); }
From source file:com.hackeruproj.android.havatzfit.log_in_activity.MainActivity.java
private void showDisclaimer() { if (!utils.isChecked(GenUtils.HAS_AGREED)) { AlertDialog.Builder disclaimer = new AlertDialog.Builder(this); disclaimer.setTitle(R.string.disclaimerHead); disclaimer.setMessage(R.string.disclaimerTheme); //positive button, save to sp the value disclaimer.setPositiveButton(R.string.posetive, new DialogInterface.OnClickListener() { @Override/*from w ww . j a va2 s . com*/ public void onClick(DialogInterface dialog, int which) { utils.saveUser(GenUtils.HAS_AGREED); //start ask for runtime permissions askRunPermission(); //finish ask for runtime permissions } }); //on negetive click exit app disclaimer.setNegativeButton(R.string.negetive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); finish(); } }); disclaimer.show(); } }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
private void showCustomEndpointDialog(final int originalSelection, String defaultUrl) { View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_endpoint, null); final EditText url = findById(view, R.id.debug_drawer_network_endpoint_url); url.setText(defaultUrl);/*from w w w .ja v a2s . c om*/ url.setSelection(url.length()); new AlertDialog.Builder(activity) // .setTitle("Set Network Endpoint").setView(view) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { endpointView.setSelection(originalSelection); dialog.cancel(); } }).setPositiveButton("Use", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { String theUrl = url.getText().toString(); if (!Strings.isBlank(theUrl)) { setEndpointAndRelaunch(theUrl); } else { endpointView.setSelection(originalSelection); } } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { endpointView.setSelection(originalSelection); } }).show(); }
From source file:com.death.yttorrents.activity.MainActivity.java
/** * @param item//ww w .j a va 2s .c o m * @return */ @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.seedr) { count += 1; Toast.makeText(MainActivity.this, "Sorting by minimum rating 8 on page " + count, Toast.LENGTH_SHORT) .show(); String url = "https://yts.ag/api/v2/list_movies.json?minimum_rating=8&limit=50&page=" + count; fetchMovies(url); } if (item.getItemId() == R.id.search) { count = 0; LayoutInflater li = LayoutInflater.from(MainActivity.this); View dialogView = li.inflate(R.layout.custom_query, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this, R.style.MyDialogTheme); alertDialogBuilder.setTitle(Html.fromHtml("<font color='#ffffff'>Search Movie</font>")); alertDialogBuilder.setIcon(R.drawable.ic_icon); alertDialogBuilder.setView(dialogView); final EditText userInput = (EditText) dialogView.findViewById(R.id.et_input); alertDialogBuilder.setCancelable(false) .setPositiveButton("Search", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { query = userInput.getText().toString(); String dataUrl = "https://yts.ag/api/v2/list_movies.json?query_term=" + query + "&limit=30"; fetchMovies(dataUrl); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } if (item.getItemId() == R.id.mwiki) { startActivity(new Intent(MainActivity.this, MediaContainer.class)); } if (item.getItemId() == R.id.about) { startActivity(new Intent(MainActivity.this, About.class)); } return super.onOptionsItemSelected(item); }
From source file:de.fhg.fokus.famium.presentation.CDVPresentationPlugin.java
private void showDisplaySelectionDialog(final PresentationSession session) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); Collection<SecondScreenPresentation> collection = getPresentations().values(); int size = collection.size(); int counter = 0; final SecondScreenPresentation presentations[] = new SecondScreenPresentation[size]; String items[] = new String[size]; for (SecondScreenPresentation presentation : collection) { presentations[counter] = presentation; items[counter++] = presentation.getDisplay().getName(); }/* ww w .j av a 2 s.com*/ builder.setTitle("Select Presentation Display").setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SecondScreenPresentation presentation = presentations[which]; session.setPresentation(presentation); getSessions().put(session.getId(), session); } }).setCancelable(false).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { session.setState(PresentationSession.DISCONNECTED); } }); AlertDialog dialog = builder.create(); dialog.show(); }