List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:br.com.GUI.perfil.SelecionarTipoDeLogin.java
@SuppressWarnings("deprecation") public void loginComFacebook() { clearFbData();/*from w w w. j a v a 2 s . c om*/ //Log.i("clicou", "logarComFacebook"); Log.i("issessionvalid", " " + String.valueOf(facebook.isSessionValid())); if (facebook.isSessionValid()) { getProfileInformation(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Carregando"); alertDialog.setMessage("Carregando informaes... Por favor, Espere alguns momentos..."); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } else { String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } if (!facebook.isSessionValid()) { facebook.authorize(this, new String[] { "publish_stream" }, new DialogListener() { //"name","email","gender","username" @Override public void onCancel() { // Function to handle cancel event } @Override public void onComplete(Bundle values) { // Function to handle complete event // Edit Preferences and update facebook acess_token SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit(); //Log.i("entrei aki ", "entrei no on complete"); getProfileInformation(); } @Override public void onError(DialogError error) { // Function to handle error } @Override public void onFacebookError(FacebookError fberror) { // Function to handle Facebook errors } }); } } }
From source file:com.Candy.sizer.CandySizer.java
private void showDialog(int id, final String item, final ArrayAdapter<String> adapter, int itemCounter) { // startup dialog final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); if (id == STARTUP_DIALOG) { // create warning dialog alert.setMessage(R.string.sizer_message_startup).setTitle(R.string.caution).setCancelable(true) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for ok dialog.cancel(); }//from w ww.j ava 2 s. co m }); // delete dialog } else if (id == DELETE_DIALOG) { alert.setMessage(R.string.sizer_message_delete) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for ok // call delete new CandySizer.SlimDeleter().execute(item); // remove list entry adapter.remove(item); adapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for cancel dialog.cancel(); } }); } else if (id == DELETE_MULTIPLE_DIALOG) { String message; if (itemCounter == 1) { message = getResources().getString(R.string.sizer_message_delete_multi_one); } else { message = getResources().getString(R.string.sizer_message_delete_multi); } alert.setMessage(message).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final ListView lv = (ListView) getView().findViewById(R.string.listsystem); ArrayList<String> itemsList = new ArrayList<String>(); SparseBooleanArray checked = lv.getCheckedItemPositions(); for (int i = lv.getCount() - 1; i > 0; i--) { if (checked.get(i)) { String appName = mSysApp.get(i); itemsList.add(appName); // remove list entry lv.setItemChecked(i, false); adapter.remove(appName); } } adapter.notifyDataSetChanged(); new CandySizer.SlimDeleter().execute(itemsList.toArray(new String[itemsList.size()])); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for cancel dialog.cancel(); } }); } else if (id == REBOOT_DIALOG) { // create warning dialog alert.setMessage(R.string.reboot).setTitle(R.string.caution).setCancelable(true) .setPositiveButton(R.string.reboot_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for ok try { dos.writeBytes("reboot"); dos.flush(); dos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).setNegativeButton(R.string.reboot_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for cancel dialog.cancel(); } }); } // show warning dialog alert.show(); }
From source file:com.arquitetaweb.observatorio.MainActivity.java
@Override public void onBackPressed() { if (isTaskRoot()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.pgtaSair).setCancelable(false) .setPositiveButton("Sim", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MainActivity.super.onBackPressed(); }// ww w .jav a2s .c om }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } else { super.onBackPressed(); } }
From source file:com.sourcey.materiallogindemo.MainActivity.java
private void MessageDialog(String msg) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); }//from w ww . j a va 2 s.c om }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.jonbanjo.cupsprint.CertificateActivity.java
private void displayCert(final String alias) { X509Certificate cert;/*ww w . j ava 2 s .co m*/ try { cert = (X509Certificate) trustStore.getCertificate(alias); } catch (KeyStoreException e) { showToast(e.toString()); return; } String certString = cert.toString(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Certificate").setMessage(certString) .setPositiveButton("Remove", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeCert(alias); } }).setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:cm.aptoide.pt.Aptoide.java
private void requestUpdateSelf() { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setCancelable(false)/*from www .j a va 2 s . c o m*/ .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); new DownloadSelfUpdate().execute(); } }).setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); proceed(); } }).setMessage(R.string.update_self_msg); AlertDialog alert = alertBuilder.create(); alert.setTitle(R.string.update_self_title); alert.setIcon(R.drawable.icon); alert.show(); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
private void DialogMap() { View dialogBoxView = View.inflate(this, R.layout.activity_map, null); final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView); String url = getString(R.string.url_map) + "index.php?poinFrom=" + txtStart.getText().toString().trim() + "&poinTo=" + txtEnd.getText().toString().trim(); map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);/*from www .ja va2 s .c o m*/ AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("Map"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }
From source file:de.baumann.hhsmoodle.data_random.Random_Fragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_help: helper_main.switchToActivity(getActivity(), Random_Help.class, false); return true; case R.id.action_dice: android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getActivity());/* w ww .jav a 2s .co m*/ View dialogView = View.inflate(getActivity(), R.layout.dialog_dice, null); final TextView textChoose2 = (TextView) dialogView.findViewById(R.id.textChoose); final EditText editNumber2 = (EditText) dialogView.findViewById(R.id.editNumber); editNumber2.setHint(R.string.number_dice_hint); builder.setView(dialogView); builder.setTitle(R.string.number_dice); builder.setPositiveButton(R.string.toast_yes, null); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final android.support.v7.app.AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button b = dialog2.getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { number = Integer.parseInt(editNumber2.getText().toString()); Random rand = new Random(); int n = rand.nextInt(number); textChoose2.setText(String.valueOf(n + 1)); } catch (NumberFormatException nfe) { Snackbar.make(textChoose2, R.string.number_dice_error, Snackbar.LENGTH_LONG).show(); nfe.printStackTrace(); } } }); } }); dialog2.show(); helper_main.showKeyboard(getActivity(), editNumber2); return true; } return super.onOptionsItemSelected(item); }
From source file:cm.aptoide.pt.ScheduledDownloads.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Builder dialogBuilder = new AlertDialog.Builder(this); final AlertDialog scheduleDialog = dialogBuilder.create(); // AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); switch (item.getItemId()) { case 0://from ww w . j a va 2 s . c o m for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { scheduledDownloadsHashMap.get(scheduledDownload).toggleChecked(); } adapter.notifyDataSetInvalidated(); break; case 1: if (isAllChecked()) { scheduleDialog.setTitle(getText(R.string.schDwnBtn)); scheduleDialog.setIcon(android.R.drawable.ic_menu_close_clear_cancel); scheduleDialog.setCancelable(false); scheduleDialog.setMessage(getText(R.string.schDown_sureremove)); scheduleDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { if (scheduledDownloadsHashMap.get(scheduledDownload).checked) { db.deleteScheduledDownload(scheduledDownload); } } getSupportLoaderManager().restartLoader(0, null, ScheduledDownloads.this); return; } }); scheduleDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); scheduleDialog.show(); } else { Toast toast = Toast.makeText(this, getString(R.string.schDown_nodownloadselect), Toast.LENGTH_SHORT); toast.show(); } break; default: break; } return true; }
From source file:com.app.swaedes.swaedes.GPSTracker.java
/** * Function to show settings alert dialog * On pressing Settings button will lauch Settings Options * *///from w w w . jav a2 s . c om public void showSettingsAlert() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); // Setting Dialog Title alertDialog.setTitle("GPS is settings"); // Setting Dialog Message alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?"); // On pressing Settings button alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); mContext.startActivity(intent); } }); // on pressing cancel button alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }