List of usage examples for android.app AlertDialog setButton2
@Deprecated public void setButton2(CharSequence text, final OnClickListener listener)
From source file:com.abcvoipsip.ui.calllog.CallLogListFragment.java
private void deleteAllCalls() { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle(R.string.callLog_delDialog_title); alertDialog.setMessage(getString(R.string.callLog_delDialog_message)); alertDialog.setButton(getString(R.string.callLog_delDialog_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null, null); }/* w w w .j a v a 2 s . c om*/ }); alertDialog.setButton2(getString(R.string.callLog_delDialog_no), (DialogInterface.OnClickListener) null); try { alertDialog.show(); } catch (Exception e) { Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog"); } }
From source file:dev.ronlemire.contactclientcloud.MainActivity.java
@SuppressWarnings("deprecation") @Override// w ww . ja va2s . com public void onBackPressed() { //super.onBackPressed(); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Exiting Application"); alertDialog.setMessage("Are you sure?"); alertDialog.setIcon(android.R.attr.alertDialogIcon); alertDialog.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); alertDialog.show(); // new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK) // .setIconAttribute(android.R.attr.alertDialogIcon) // .setTitle(R.string.exitingApplication) // .setMessage(R.string.shortMessage) // .setPositiveButton(R.string.alert_dialog_ok, // new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, // int whichButton) { // finish(); // } // }) // .setNegativeButton(R.string.alert_dialog_cancel, // new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, // int whichButton) { // return; // } // }).create().show(); }
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();/*w w w . j a v a 2s . c o m*/ AlertDialog alertDialog1 = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this) .create(); // 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:cm.aptoide.pt.RemoteInTab.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == NEWREPO_FLAG) { if (data != null && data.hasExtra("update")) { final AlertDialog alrt = new AlertDialog.Builder(this).create(); alrt.setTitle("Update repositories"); alrt.setMessage("The list of repositories in use has been changed.\nDo you wish to update them?"); alrt.setButton("Yes", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateRepos();/*from w w w.j ava2 s.com*/ } }); alrt.setButton2("No", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); } } else if (requestCode == SETTINGS_FLAG) { if (data != null && data.hasExtra("align")) { order_lst = data.getExtras().getString("align"); prefEdit.putString("order_lst", order_lst); prefEdit.commit(); } } }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog/*from www. ja v a2s . com*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:foam.littlej.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog//from w w w . j av a2s . c o m */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete any existing photo in the pending folder new DiscardTask(AddCheckinActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:cm.aptoide.pt.ManageRepo.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.repolist);/*from w w w . j a v a2 s .c o m*/ db = new DbHandler(this); Intent i = getIntent(); if (i.hasExtra("empty")) { final String uri = i.getStringExtra("uri"); AlertDialog alrt = new AlertDialog.Builder(this).create(); alrt.setTitle(getString(R.string.title_repo_alrt)); alrt.setIcon(android.R.drawable.ic_dialog_alert); alrt.setMessage(getString(R.string.myrepo_alrt) + uri); alrt.setButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { db.addServer(uri); change = true; redraw(); return; } }); alrt.setButton2("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alrt.show(); } else if (i.hasExtra("uri")) { String uri = i.getStringExtra("uri"); Vector<String> new_serv_lst = getRemoteServLst(uri); for (final String srv : new_serv_lst) { AlertDialog alrt = new AlertDialog.Builder(this).create(); alrt.setTitle(getString(R.string.title_repo_alrt)); alrt.setIcon(android.R.drawable.ic_dialog_alert); alrt.setMessage(getString(R.string.newrepo_alrt) + srv); alrt.setButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { db.addServer(srv); change = true; redraw(); return; } }); alrt.setButton2("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alrt.show(); } } else if (i.hasExtra("newrepo")) { final String repo = i.getStringExtra("newrepo"); AlertDialog alrt = new AlertDialog.Builder(this).create(); alrt.setTitle(getString(R.string.title_repo_alrt)); alrt.setIcon(android.R.drawable.ic_dialog_alert); alrt.setMessage(getString(R.string.newrepo_alrt) + repo); alrt.setButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { db.addServer(repo); change = true; redraw(); return; } }); alrt.setButton2("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //exit } }); alrt.show(); } }
From source file:com.glm.trainer.NewMainActivity.java
/** * Visualizza una alert per il GPS non abilitato * * @author Gianluca Masci aka (GLM)/*from w ww . jav a 2 s . c om*/ * */ public void ShowAlertNoGPS() { try { AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(this.getString(R.string.titlegps)); alertDialog.setMessage(this.getString(R.string.messagegpsnoenabled)); alertDialog.setButton(this.getString(R.string.yes), new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(myIntent); } }); alertDialog.setButton2(this.getString(R.string.no), new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { } }); alertDialog.show(); } catch (Exception e) { Toast.makeText(this, "ERROR DIALOG:" + e.getMessage(), Toast.LENGTH_SHORT).show(); Log.e("MEEERR: ", e.getMessage()); } }
From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/*from ww w. j a v a2 s .c o m*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.android.quake.llvm.DownloaderActivity.java
private void onDownloadFailed(String reason) { Log.e(LOG_TAG, "Download stopped: " + reason); String shortReason;/*from w w w . jav a 2 s . com*/ int index = reason.indexOf('\n'); if (index >= 0) { shortReason = reason.substring(0, index); } else { shortReason = reason; } AlertDialog alert = new Builder(this).create(); alert.setTitle(R.string.download_activity_download_stopped); if (!mSuppressErrorMessages) { alert.setMessage(shortReason); } alert.setButton(getString(R.string.download_activity_retry), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startDownloadThread(); } }); alert.setButton2(getString(R.string.download_activity_quit), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); try { alert.show(); } catch (WindowManager.BadTokenException e) { // Happens when the Back button is used to exit the activity. // ignore. } }