List of usage examples for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener
DialogInterface.OnClickListener
From source file:de.grundid.plusrad.MainActivity.java
private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(//from www . j a va2s . co m "Your phone's GPS is disabled. Cycle Philly needs GPS to determine your location.\n\nGo to System Settings now to enable GPS?") .setCancelable(false).setPositiveButton("GPS Settings...", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { final Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:io.coldstart.android.TrapDetailFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.DeleteTraps: { new AlertDialog.Builder(getActivity()).setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Delete Traps for selected host?") .setMessage("Are you sure you want to delete all the traps from host " + hostname + "?") .setPositiveButton("Yes, Delete", new DialogInterface.OnClickListener() { @Override/*from w ww . j a v a 2 s. com*/ public void onClick(DialogInterface dialog, int which) { Log.i("onOptionsItemSelected", "Deleting Traps"); (new Thread() { public void run() { datasource = new TrapsDataSource(getActivity()); datasource.open(); datasource.deleteHost(ipaddr); datasource.close(); if (twoPane) { Intent broadcast = new Intent(); broadcast.setAction(API.BROADCAST_ACTION); getActivity().sendBroadcast(broadcast); Bundle arguments = new Bundle(); arguments.putString(TrapDetailFragment.ARG_HOSTNAME, hostname); PendingDeleteFragment fragment = new PendingDeleteFragment(); fragment.setArguments(arguments); getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.trap_detail_container, fragment).commit(); } else { ((TrapDetailActivity) getActivity()).exitOnDelete(); } } }).start(); } }).setNegativeButton("No", null).show(); return true; } case R.id.ImportSNMP: { new AlertDialog.Builder(getActivity()).setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Poll Host for SNMP Agent Details") .setMessage("Scans " + hostname + " from the ColdStart servers [ 89.151.79.202 ] using your SNMP community to get the location, description etc.\n\n" + "Ensure that the relevant firewall ports / permissions are configured.") .setPositiveButton("Yes, Scan", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { (new Thread() { public void run() { SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(getActivity()); try { API api = new API(); final ColdStartHost host = api .scanRemoteHost(settings.getString("APIKey", ""), ipaddr); if (host.Error) { getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getActivity(), host.ErrorMsg, Toast.LENGTH_SHORT) .show(); } }); } else { datasource = new TrapsDataSource(getActivity()); datasource.open(); if (datasource.addHostDetails(host)) { getActivity().runOnUiThread(new Runnable() { public void run() { if (twoPane) { try { ((TextView) getActivity() .findViewById(R.id.Location)) .setText(host.Location); ((TextView) getActivity() .findViewById(R.id.Description)) .setText(host.Description); ((TextView) getActivity() .findViewById(R.id.Contact)) .setText(host.Contact); } catch (Exception e) { //This is really lazy we should probably have a handler for this e.printStackTrace(); } } else { //TODO Add some UI elements to the phone view for this data Toast.makeText(getActivity(), host.Location + "\n" + host.Description + "\n" + host.Contact, Toast.LENGTH_SHORT).show(); } } }); } } } catch (Exception e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getActivity(), "There was an internal error when trying to do the scan", Toast.LENGTH_SHORT).show(); } }); } finally { try { datasource.close(); } catch (Exception e) { e.printStackTrace(); } } /*if (twoPane) { Intent broadcast = new Intent(); broadcast.setAction(API.BROADCAST_ACTION); getActivity().sendBroadcast(broadcast); Bundle arguments = new Bundle(); arguments.putString(TrapDetailFragment.ARG_HOSTNAME, hostname); PendingDeleteFragment fragment = new PendingDeleteFragment(); fragment.setArguments(arguments); getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.trap_detail_container, fragment).commit(); } else { ((TrapDetailActivity) getActivity()).exitOnDelete(); }*/ } } ). start(); } } ). setNegativeButton("No", null) . show(); return true; } } return false; }
From source file:com.coinblesk.client.wallet.WalletAddressList.java
private void showAmountTooSmallDialog(Coin amount) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogAccent); AlertDialog dialog = builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() { @Override//from w w w. java2s. co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setTitle(R.string.dialog_refund_too_small_title) .setMessage(getString(R.string.dialog_refund_too_small_message, amount.toFriendlyString())) .create(); dialog.show(); }
From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java
public boolean checkStackTrace() { FileInputStream traceIn = null; try {//from w w w . jav a 2s .co m traceIn = openFileInput("stack.trace"); traceIn.close(); } catch (FileNotFoundException fnfe) { // No stack trace available return false; } catch (IOException ioe) { return false; } AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setMessage(getResources().getString(R.string.crashreport_msg)); alert.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.emailstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String trace = ""; String line = null; try { BufferedReader reader = new BufferedReader( new InputStreamReader(TwitSpeakActivity.this.openFileInput("stack.trace"))); while ((line = reader.readLine()) != null) { trace += line + "\n"; } } catch (FileNotFoundException fnfe) { Log.logException(TAG, fnfe); } catch (IOException ioe) { Log.logException(TAG, ioe); } Intent sendIntent = new Intent(Intent.ACTION_SEND); String subject = "Error report"; String body = getResources().getString(R.string.mailthisto_msg) + " jayesh@altcanvas.com: " + "\n\n" + G.getPhoneInfo() + "\n\n" + "TwitSpeak [" + G.VERSION_STRING + "]" + "\n\n" + trace + "\n\n"; sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jayesh@altcanvas.com" }); sendIntent.putExtra(Intent.EXTRA_TEXT, body); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("message/rfc822"); TwitSpeakActivity.this.startActivityForResult( Intent.createChooser(sendIntent, getResources().getString(R.string.emailstr)), G.REQCODE_EMAIL_STACK_TRACE); TwitSpeakActivity.this.deleteFile("stack.trace"); } }); alert.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancelstr), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { TwitSpeakActivity.this.deleteFile("stack.trace"); TwitSpeakActivity.this.continueOnCreate(); } }); alert.show(); return true; }
From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java
private void showDownloadDialog(final String userAgent, final String content, final String mimeType, final long contentLength) { String hostUrl = ""; try {/* w w w . j av a2s.c om*/ hostUrl = new URL(fileUrl).getHost(); } catch (MalformedURLException e) { hostUrl = fileUrl; } String title = getString(R.string.externallink_download_title); String message = format(getString(R.string.externallink_download_message), fileName, hostUrl); AlertDialog.Builder builder = DialogUtitities.getAlertDialogBuilderWithMessageAndTitle(this, message, title); builder.setPositiveButton(getString(R.string.externallink_download_title), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { ExternalDownloadManager dm = new ExternalDownloadManager(getApplicationContext()); dm.downloadFile(fileName, fileUrl, userAgent, content, mimeType, contentLength); dialog.dismiss(); } }).setCancelable(false) .setNegativeButton(getString(R.string.abort), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); finish(); } }).setNeutralButton(R.string.externallink_actionbar_open_in_browser, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { openInExternalApp(webView.getUrl()); dialog.dismiss(); finish(); } }); builder.create().show(); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { //add pair to dashboard action case R.id.action_add: final CheckBoxListAdapter checkBoxListAdapter = new CheckBoxListAdapter(getActivity(), getResources().getStringArray(R.array.ExchangePairs), CheckBoxListAdapter.SettingsScope.PAIRS); ListView listView = new ListView(getActivity()); listView.setAdapter(checkBoxListAdapter); new AlertDialog.Builder(getActivity()).setTitle(this.getString(R.string.SelectPairsPromptTitle)) .setView(listView).setNeutralButton(getResources().getString(R.string.DialogSaveButton), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { checkBoxListAdapter.saveValuesToPreferences(); updateStorageWithTickers(); mTickersDashboardAdapter.update(); getActivity() .sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class)); }/*from w w w . j a v a 2s. c o m*/ }) .show(); break; //refresh dashboard action case R.id.action_refresh: mRefreshItem = item; mRefreshItem.setActionView(R.layout.progress_bar_action_view); mRefreshItem.expandActionView(); getActivity().sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class)); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:net.ustyugov.jtalk.activity.note.NotesActivity.java
private void createDialog(final String account, final Note note) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.note_dialog, (ViewGroup) findViewById(R.id.note_linear)); String text = ""; String title = ""; String tag = ""; if (note != null) { text = note.getText();/*w ww . ja v a 2 s .co m*/ title = note.getTittle(); tag = note.getTag(); } final EditText textEdit = (EditText) layout.findViewById(R.id.text_edit); if (text != null) textEdit.setText(text); final EditText titleEdit = (EditText) layout.findViewById(R.id.title_edit); if (title != null) titleEdit.setText(title); final EditText tagEdit = (EditText) layout.findViewById(R.id.tag_edit); if (tag != null) tagEdit.setText(tag); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setTitle(R.string.Add); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String text = textEdit.getText().toString(); String title = titleEdit.getText().toString(); String tag = tagEdit.getText().toString(); if (text != null && text.length() > 0) { try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); if (note != null) { nm.removeNote(note); } nm.addNote(new Note(title, text, tag)); updateNotes(); } catch (Exception ignored) { } } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:cx.ring.client.AccountEditionActivity.java
private AlertDialog createDeleteDialog() { Activity ownerActivity = this; AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity); builder.setMessage("Do you really want to delete this account").setTitle("Delete Account") .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override/* w w w . ja v a 2 s .co m*/ public void onClick(DialogInterface dialog, int whichButton) { Bundle bundle = new Bundle(); bundle.putString("AccountID", acc_selected.getAccountID()); try { service.getRemoteService().removeAccount(acc_selected.getAccountID()); } catch (RemoteException e) { e.printStackTrace(); } finish(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { /* Terminate with no action */ } }); AlertDialog alertDialog = builder.create(); alertDialog.setOwnerActivity(ownerActivity); return alertDialog; }
From source file:net.ustyugov.jtalk.activity.note.TemplatesActivity.java
private void createDialog(final String account, final Note note) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.note_dialog, (ViewGroup) findViewById(R.id.note_linear)); String text = ""; if (note != null) text = note.getText();//from w ww . j a v a 2s . c o m final EditText edit = (EditText) layout.findViewById(R.id.text_edit); if (text != null) edit.setText(text); EditText title = (EditText) layout.findViewById(R.id.title_edit); title.setVisibility(View.GONE); EditText tag = (EditText) layout.findViewById(R.id.tag_edit); tag.setVisibility(View.GONE); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout); builder.setTitle(R.string.Add); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String message = edit.getText().toString(); if (message != null && message.length() > 0) { try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); String title = ""; if (note != null) { title = note.getTittle(); nm.removeNote(note); } nm.addNote(new Note(title, message, "template")); updateNotes(); } catch (Exception ignored) { } } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java
private void showPermissionsDialog() { String message = getString(R.string.externallink_permissions); final Activity activity = this; AlertDialog.Builder builder = DialogUtitities.getAlertDialogBuilderWithMessage(activity, message); builder.setPositiveButton(getString(R.string.externallink_continue), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { Permissions.requestWritePermissionsIfMissing(activity, activity); dialog.dismiss();/*from w w w. j av a2 s . c o m*/ } }).setCancelable(false).setNegativeButton(getString(R.string.abort), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); finish(); } }); builder.create().show(); }