List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:co.carlosjimenez.android.currencyalerts.app.DetailActivityFragment.java
/** * Helper method to open a notification that there is an existing alert * * @param currencyFrom String containing the currency from id * @param currencyTo String containing the currency to id *///from w w w . j a v a 2 s.c om private void openExistingAlertDialog(String currencyFrom, String currencyTo) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); // set dialog message alertDialogBuilder.setMessage(getString(R.string.dialog_existing_alert, currencyFrom, currencyTo)) .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); openCreateAlertDialog(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, just close // the dialog box and do nothing dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
protected void setPassphrase(final int deviceIdx) { final EditText fld_passphrase = new EditText(TapLockSettings.this); // parse the existing passphrase JSONObject deviceJObj = mDevices.get(deviceIdx); try {/*ww w . java2s. co m*/ fld_passphrase.setText(deviceJObj.getString(KEY_PASSPHRASE)); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle("set passphrase").setView(fld_passphrase) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String passphrase = fld_passphrase.getText().toString(); JSONObject deviceJObj = mDevices.remove(deviceIdx); try { deviceJObj.put(KEY_PASSPHRASE, passphrase); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } mDevices.add(deviceIdx, deviceJObj); if (mServiceInterface != null) { try { mServiceInterface.write(deviceJObj.getString(KEY_ADDRESS), ACTION_PASSPHRASE, passphrase); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } } else storeDevices(); } }).create(); mDialog.show(); }
From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java
private void showLoginDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(ViewRedditActivity.this); // Get the layout inflater LayoutInflater inflater = getLayoutInflater(); final View v = inflater.inflate(R.layout.logindialog, null); builder.setView(v)// w w w . ja v a 2 s . c om // Add action buttons .setPositiveButton("Login", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { final String username = ((EditText) v.findViewById(R.id.username)).getText().toString(); final String password = ((EditText) v.findViewById(R.id.password)).getText().toString(); final boolean rememberaccn = ((CheckBox) v.findViewById(R.id.rememberaccn)).isChecked(); dialog.cancel(); // run login procedure final ProgressDialog logindialog = android.app.ProgressDialog.show(ViewRedditActivity.this, "", ("Logging in..."), true); Thread t = new Thread() { public void run() { // login final String result = global.mRedditData.checkLogin(prefs, username, password, rememberaccn); // request "remember" cookie if account is being saved // Set thread network policy to prevent network on main thread exceptions. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll() .build(); StrictMode.setThreadPolicy(policy); runOnUiThread(new Runnable() { public void run() { logindialog.dismiss(); if (result.equals("1")) { if (rememberaccn) { // store account if requested & login result is OK global.setAccount(prefs, username, password, true); } } else { // show error Toast.makeText(ViewRedditActivity.this, "Login error: " + result, Toast.LENGTH_LONG).show(); } } }); } }; t.start(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setTitle("Login to Reddit"); builder.create().show(); }
From source file:com.example.linhdq.test.documents.viewing.single.DocumentActivity.java
private void deleteDocument() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.delete_whole_document); builder.setMessage(getString(R.string.delete_document_message)); builder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a2 s .co m*/ public void onClick(DialogInterface dialog, int which) { Set<Integer> idToDelete = new HashSet<>(); idToDelete.add(getParentId()); new DeleteDocumentTask(idToDelete, true).execute(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.example.notesapp.notedetail.NoteDetailFragment.java
public void showDeleteConfirmationDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Delete this note"); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String noteId = getArguments().getString(ARGUMENT_NOTE_ID); String serverId = getArguments().getString(ARGUMENT_SERVER_ID); Intent intent = new Intent(getActivity(), ServerSyncService.class); intent.putExtra("action", ServerConstants.ACTION_DELETE); intent.putExtra("id", noteId); intent.putExtra("serverId", serverId); getActivity().startService(intent); mActionsListener.deleteNote(noteId); }//from w ww.ja va 2 s .co m }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // Create the AlertDialog object and return it builder.create().show(); }
From source file:au.org.ala.fielddata.mobile.MobileFieldDataDashboard.java
private void showNoGpsDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Enable GPS?").setMessage( "The GPS on this device is currently disabled, do you want to enable it? \nEnabling GPS will allow accurate survey locations to be recorded.") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/*from ww w. jav a2 s . co m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); builder.create().show(); askedAboutGPS = true; }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.button_add_device) addDevice();//w ww . j av a2 s .com else if (itemId == R.id.button_about) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.button_about) .setMessage(R.string.about) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources().getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT).show(); else if (ACTION_DOWNLOAD_EMAIL.equals(action) && copyFileToSDCard(installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).setPositiveButton(R.string.button_license, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.button_license).setMessage(R.string.license).create(); mDialog.show(); } }).create(); mDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:com.coinprism.wallet.fragment.SendTab.java
private void showSuccess(final String transactionId) { WalletState.getState().getBalanceTab().triggerRefresh(); WalletState.getState().getTransactionsTab().triggerRefresh(); final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this.getActivity()); // Setting Dialog Title alertDialog.setTitle(getString(R.string.tab_send_dialog_transaction_success_title)); alertDialog.setMessage(getString(R.string.tab_send_dialog_transaction_successful_message)); this.amount.setText(""); this.toAddress.setText(""); alertDialog.setPositiveButton(getString(R.string.tab_send_dialog_transaction_successful_see), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String url = String.format(getString(R.string.link_transaction), transactionId); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); }/*from www. ja va2 s .c om*/ }); alertDialog.setNegativeButton(getString(R.string.tab_send_dialog_transaction_successful_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
private void showAlertView(MBPage page) { if (getCurrentAlert() != null) { getCurrentAlert().dismiss();/* ww w. j a va2 s. c o m*/ } String title = null; String message = null; MBDocument pageDoc = page.getDocument(); final AlertDialog.Builder builder = new AlertDialog.Builder(this); boolean buildDefault = true; if (pageDoc.getName().equals(MBConfigurationDefinition.DOC_SYSTEM_EXCEPTION)) { title = pageDoc.getValueForPath(MBConfigurationDefinition.PATH_SYSTEM_EXCEPTION_NAME); message = pageDoc.getValueForPath(MBConfigurationDefinition.PATH_SYSTEM_EXCEPTION_DESCRIPTION); } else { title = page.getTitle(); message = MBLocalizationService.getInstance() .getTextForKey((String) pageDoc.getValueForPath("/message[0]/@text")); if (message == null) { message = MBLocalizationService.getInstance() .getTextForKey((String) pageDoc.getValueForPath("/message[0]/@text()")); } try { MBElement buttons = pageDoc.getValueForPath("/buttons[0]"); MBElement neutral = buttons.getValueForPath("/neutral[0]"); MBElement negative = buttons.getValueForPath("/negative[0]"); MBElement positive = buttons.getValueForPath("/positive[0]"); builder.setMessage(message).setTitle(title).setCancelable(true); buildAlertDialogButtons(builder, neutral); buildAlertDialogButtons(builder, negative); buildAlertDialogButtons(builder, positive); buildDefault = false; } catch (MBInvalidPathException e) { Log.w(Constants.APPLICATION_NAME, "Popup document " + pageDoc.getName() + " has no buttons defined. Adding neutral button Ok"); } } if (buildDefault) { builder.setMessage(message).setTitle(title).setCancelable(true).setNeutralButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); } runOnUiThread(new Runnable() { @Override public void run() { Dialog dialog = builder.create(); dialog.show(); setCurrentAlert(dialog); } }); }