List of usage examples for android.app AlertDialog setButton
@Deprecated public void setButton(CharSequence text, final OnClickListener listener)
From source file:org.odk.collect.android.activities.FormHierarchyActivity.java
/** * Creates and displays dialog with the given errorMsg. *///from ww w . ja v a2 s . com private void createErrorDialog(String errorMsg) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "show."); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertDialog.setTitle(getString(R.string.error_occured)); alertDialog.setMessage(errorMsg); DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON_POSITIVE: Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "OK"); FormController formController = Collect.getInstance().getFormController(); formController.jumpToIndex(currentIndex); break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), errorListener); alertDialog.show(); }
From source file:com.awrtechnologies.carbudgetsales.MainActivity.java
/** * Function to display simple Alert Dialog * * @param context - application context/*from w w w. j a va 2s. c o m*/ * @param title - alert dialog title * @param message - alert message * @param status - success/failure (used to set icon) */ public void showAlertDialog(Context context, String title, String message, Boolean status) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); // Setting Dialog Title alertDialog.setTitle(title); // Setting Dialog Message alertDialog.setMessage(message); // Setting alert dialog icon alertDialog.setIcon((status) ? R.drawable.transparentlogo : R.drawable.transparentlogo); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { MainActivity.this.finish(); dialog.dismiss(); } }); // Showing Alert Message alertDialog.show(); }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
private void createAlertDialog(String message) { Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show"); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.download_forms_result)); alertDialog.setMessage(message);//ww w . j a v a 2 s . c om DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON1: // ok Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "OK"); alertShowing = false; finish(); break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), quitListener); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertShowing = true; alertMsg = message; alertDialog.show(); }
From source file:cm.aptoide.pt.ManageRepo.java
private void editRepo(final String repo) { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.addrepo, null); Builder p = new AlertDialog.Builder(this).setView(view); final AlertDialog alrt = p.create(); final EditText uri = (EditText) view.findViewById(R.id.edit_uri); uri.setText(repo);/*from w w w. ja va 2 s . c o m*/ final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); } } }); String[] logins = null; logins = db.getLogin(repo); if (logins != null) { sec.setChecked(true); sec_user.setText(logins[0]); sec_pwd.setText(logins[1]); } else { sec.setChecked(false); } alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Edit repository"); alrt.setButton("Done", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String new_repo = uri.getText().toString(); db.updateServer(repo, new_repo); if (sec.isChecked()) { db.addLogin(sec_user.getText().toString(), sec_pwd.getText().toString(), new_repo); } else { db.disableLogin(new_repo); } change = true; redraw(); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alert2.dismiss(); alrt.show(); }
From source file:cm.aptoide.pt.RemoteInSearch.java
@Override protected void onListItemClick(ListView l, View v, final int position, long id) { super.onListItemClick(l, v, position, id); Vector<String> tmp_get = db.getApk(apk_lst.get(position).apkid); String tmp_path = this.getString(R.string.icons_path) + apk_lst.get(position).apkid; File test_icon = new File(tmp_path); LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.alertscroll, null); Builder alrt = new AlertDialog.Builder(this).setView(view); final AlertDialog p = alrt.create(); if (test_icon.exists() && test_icon.length() > 0) { p.setIcon(new BitmapDrawable(tmp_path)); } else {//from w w w. java 2 s . c o m p.setIcon(android.R.drawable.sym_def_app_icon); } p.setTitle(apk_lst.get(position).name); TextView t1 = (TextView) view.findViewById(R.id.n11); t1.setText(tmp_get.firstElement()); TextView t2 = (TextView) view.findViewById(R.id.n22); t2.setText(tmp_get.get(1)); TextView t3 = (TextView) view.findViewById(R.id.n33); t3.setText(tmp_get.get(2)); TextView t4 = (TextView) view.findViewById(R.id.n44); t4.setText(tmp_get.get(3)); TextView t5 = (TextView) view.findViewById(R.id.n55); String tmpi = db.getDescript(apk_lst.get(position).apkid); if (!(tmpi == null)) { t5.setText(tmpi); } else { t5.setText("No info availale on server. Search market by pressing the button below for more info."); } p.setButton2("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); if (tmp_get.get(2).equalsIgnoreCase("\tno\n")) { p.setButton(getString(R.string.install), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); new Thread() { public void run() { String apk_pkg = downloadFile(position); if (apk_pkg == null) { Message msg = new Message(); msg.arg1 = 1; download_handler.sendMessage(msg); download_error_handler.sendEmptyMessage(0); } else { installApk(apk_pkg, position); } } }.start(); } }); p.setButton3("Search Market", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid)); startActivity(intent); } }); } else { p.setButton(getString(R.string.rem), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String apk_pkg = apk_lst.get(position).apkid; removeApk(apk_pkg, position); } }); if (apk_lst.get(position).status == 2) { p.setButton3(getString(R.string.update), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); new Thread() { public void run() { String apk_pkg = downloadFile(position); if (apk_pkg == null) { //Toast.makeText(RemoteInSearch.this, "Could not connect to server!", Toast.LENGTH_LONG).show(); Message msg = new Message(); msg.arg1 = 1; download_handler.sendMessage(msg); download_error_handler.sendEmptyMessage(0); } else { installApk(apk_pkg, position); } } }.start(); } }); } else { p.setButton3("Search Market", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid)); startActivity(intent); } }); } } p.show(); }
From source file:org.csp.everyaware.offline.Map.java
public final void createLegalNoticesDialog(Activity activity) { AlertDialog ad = new AlertDialog.Builder(activity).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(activity.getApplicationContext())); ad.setButton("OK", new DialogInterface.OnClickListener() { @Override/*from ww w.j a va 2s .c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); }
From source file:com.picogram.awesomeness.SettingsActivity.java
public boolean onPreferenceClick(final Preference preference) { if (preference.getKey().equals("statistics")) { //TODO//from w w w . j ava 2 s.c o m Crouton.makeText(this, "This is not yet implemented", Style.INFO).show(); final AlertDialog dialog = new AlertDialog.Builder(this).create(); final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle", "Tapes per Minute", "Times Played" }; final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0; final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed }; // TODO: Implement the preferences and what not. final LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i != scores.length; ++i) { final LinearLayout sub = new LinearLayout(this); sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); sub.setOrientation(LinearLayout.HORIZONTAL); TextView tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scoresTitles[i]); sub.addView(tv); tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scores[i] + ""); sub.addView(tv); ll.addView(sub); } dialog.setView(ll); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; dialog.show(); dialog.dismiss(); return true; } else if (preference.getKey().equals("changelog")) { // Launch change log dialog final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this); _ChangelogDialog.show(); } else if (preference.getKey().equals("licenses")) { // Launch the licenses stuff. Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create(); ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; ld.show(); } else if (preference.getKey().equals("email")) { final String email = "warner.73+Picogram@wright.edu"; final String subject = "Picogram - <SUBJECT>"; final String message = "Picogram,\n\n<MESSAGE>"; // Contact me. final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, message); emailIntent.setType("message/rfc822"); this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :")); overridePendingTransition(R.anim.fadein, R.anim.exit_left); } else if (preference.getKey().equals("rateapp")) { // TODO fix this when we publish. this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram"))); overridePendingTransition(R.anim.fadein, R.anim.exit_left); final Editor editor = this.prefs.edit(); editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true); editor.commit(); } else if (preference.getKey().equals("logoutgoogle")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("logoutfacebook")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("resetusername")) { Util.getPreferences(this).edit().putString("username", "").commit(); Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit(); } return false; }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog//from w w w . ja va 2 s. c om */ @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 ww .ja va2 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) { 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:com.ushahidi.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/*from w ww. j a va2 s . c om*/ */ @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; }