List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Selected menu item id: " + String.valueOf(item.getItemId())); }//from w w w. ja va2 s . c o m final AlertDialog.Builder builder = new AlertDialog.Builder(this); View v; ListViewHolder viewHolder; AdapterView.AdapterContextMenuInfo contextInfo; String app_name; final String package_name; switch (item.getItemId()) { case R.id.btnUncheckAll: builder.setTitle(R.string.dialog_confirm_title); builder.setMessage(getString(R.string.dialog_uncheck_message)); builder.setCancelable(false); builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (lvPackages == null || lvPackages.getAdapter() == null || ((packageAdapter) lvPackages.getAdapter()).selected == null) { //something went wrong return; } ((packageAdapter) lvPackages.getAdapter()).selected.clear(); lvPackages.invalidateViews(); } }); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { //do nothing! } }); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.show(); return true; case R.id.btnSave: finish(); return true; case R.id.btnDonate: Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(Constants.DONATION_URL)); startActivity(i); return true; case R.id.btnSettings: Intent settings = new Intent(this, SettingsActivity.class); startActivity(settings); return true; case R.id.btnRename: contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) v = contextInfo.targetView; app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString(); viewHolder = (ListViewHolder) v.getTag(); if (viewHolder == null || viewHolder.chkEnabled == null) { //failure return true; } package_name = (String) viewHolder.chkEnabled.getTag(); builder.setTitle(R.string.dialog_title_rename_notification); final EditText input = new EditText(this); input.setHint(app_name); builder.setView(input); builder.setPositiveButton(R.string.confirm, null); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); final AlertDialog d = builder.create(); d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button b = d.getButton(AlertDialog.BUTTON_POSITIVE); if (b != null) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //can't be nothing if (input.getText().length() > 0) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Adding rename for " + package_name + " to " + input.getText()); } JSONObject rename = new JSONObject(); try { rename.put("pkg", package_name); rename.put("to", input.getText()); arrayRenames.put(rename); } catch (JSONException e) { e.printStackTrace(); } ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged(); d.dismiss(); } else { input.setText(R.string.error_cant_be_blank); } } }); } } }); d.show(); return true; case R.id.btnRemoveRename: contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // the child view who's info we're viewing (should be equal to v) v = contextInfo.targetView; app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString(); viewHolder = (ListViewHolder) v.getTag(); if (viewHolder == null || viewHolder.chkEnabled == null) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Viewholder is null or chkEnabled is null"); } //failure return true; } package_name = (String) viewHolder.chkEnabled.getTag(); builder.setTitle( getString(R.string.dialog_title_remove_rename) + app_name + " (" + package_name + ")?"); builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Before remove is: " + String.valueOf(arrayRenames.length())); } JSONArray tmp = new JSONArray(); try { for (int i = 0; i < arrayRenames.length(); i++) { if (!arrayRenames.getJSONObject(i).getString("pkg").equalsIgnoreCase(package_name)) { tmp.put(arrayRenames.getJSONObject(i)); } } } catch (JSONException e) { e.printStackTrace(); } arrayRenames = tmp; if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "After remove is: " + String.valueOf(arrayRenames.length())); } ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged(); } }); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); builder.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:net.evecom.android.PublicOpinionLookActivity.java
/** * // ww w.ja va2 s.c om */ private String submit() { /** */ if (ztEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (fsddEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (lylxButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (years == 0 || month == 0 || day == 0) { DialogToast(""); return ""; } else if (lyrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (xxnrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (lxdhEditText.getText().toString().trim().length() >= 1) { if (isCellphone(lxdhEditText.getText().toString().trim()) == false) { DialogToast(""); return ""; } } if ("4".equals(zt1)) { DialogToast(""); return ""; } else if ("2".equals(zt1)) { DialogToast(""); return ""; } else if ("3".equals(zt1)) { DialogToast(""); return ""; } final AlertDialog.Builder builder = new AlertDialog.Builder(PublicOpinionLookActivity.this); builder.setTitle(""); builder.setIcon(R.drawable.qq_dialog_default_icon);// builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { progressDialog = ProgressDialog.show(PublicOpinionLookActivity.this, "", "..."); formSubmit1(); } }); builder.setNegativeButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); return "1"; }
From source file:net.evecom.android.PublicOpinionLookActivity.java
/** * /* w ww.j a va 2 s . com*/ * * @param v */ public void opinionfh(View v) { final AlertDialog.Builder builder = new AlertDialog.Builder(PublicOpinionLookActivity.this); builder.setTitle(""); builder.setIcon(R.drawable.qq_dialog_default_icon);// builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { finish(); Intent intent = new Intent(getApplicationContext(), PublicOpinionlistActivity.class); startActivity(intent); } }); builder.setNegativeButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); }
From source file:com.vegnab.vegnab.MainVNActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. Tracker optionsMenuTracker = ((VNApplication) getApplication()) .getTracker(VNApplication.TrackerName.APP_TRACKER); FragmentManager fm = getSupportFragmentManager(); DialogFragment editProjDlg;//from w w w . j ava 2 s. c om switch (item.getItemId()) { // some of these are from Fragments, but handled here in the Activity case R.id.action_app_info: Toast.makeText(getApplicationContext(), "''App Info'' is not implemented yet", Toast.LENGTH_SHORT) .show(); return true; case R.id.action_legal_notices: // following is required, to use Drive API String legalInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this); AlertDialog.Builder legalInfoDialog = new AlertDialog.Builder(this); legalInfoDialog.setTitle(this.getResources().getString(R.string.action_legal_notices)); legalInfoDialog.setMessage(legalInfo); legalInfoDialog.show(); return true; case R.id.action_edit_proj: // EditProjectDialog editProjDlg = new EditProjectDialog(); /* fm.executePendingTransactions(); // assure all are done NewVisitFragment newVis = (NewVisitFragment) fm.findFragmentByTag("NewVisitScreen"); if (newVis == null) { Toast.makeText(getApplicationContext(), "Can't get New Visit Screen fragment", Toast.LENGTH_SHORT).show(); return true; } // wait, we don't need to regenerate the default project Id, it's stored in Preferences*/ SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); long defaultProjId = sharedPref.getLong(Prefs.DEFAULT_PROJECT_ID, 1); editProjDlg = EditProjectDialog.newInstance(defaultProjId); editProjDlg.show(fm, "frg_edit_proj"); return true; case R.id.action_new_proj: editProjDlg = EditProjectDialog.newInstance(0); editProjDlg.show(fm, "frg_new_proj"); return true; case R.id.action_del_proj: DelProjectDialog delProjDlg = new DelProjectDialog(); delProjDlg.show(fm, "frg_del_proj"); return true; case R.id.action_new_plottype: // Toast.makeText(getApplicationContext(), "''New Plot Type'' is still under construction", Toast.LENGTH_SHORT).show(); showWebViewScreen(Tags.WEBVIEW_PLOT_TYPES); /* public static final String WEBVIEW_TUTORIAL = "WebviewTutorial"; public static final String WEBVIEW_PLOT_TYPES = "WebviewPlotTypes"; public static final String WEBVIEW_REGIONAL_LISTS = "WebviewSppLists"; */ return true; case R.id.action_get_species: goToGetSppScreen(); return true; case R.id.action_export_db: exportDB(); return true; // following, moved to NewVisit fragment // case R.id.action_unhide_visits: // from New Visit fragment // if (mCtHiddenVisits == 0) { // Toast.makeText(this, // this.getResources().getString(R.string.new_visit_unhide_visit_none), // Toast.LENGTH_SHORT).show(); // } else { //// Toast.makeText(getApplicationContext(), mCtHiddenVisits + " hidden visit(s), but " //// + "''Un-hide Visits'' is not implemented yet", Toast.LENGTH_SHORT).show(); // UnHideVisitDialog unHideVisDlg = new UnHideVisitDialog(); // unHideVisDlg.show(fm, "frg_unhide_vis"); // } // return true; case R.id.action_settings: if (LDebug.ON) Log.d(LOG_TAG, "Showing 'Settings' dialog"); optionsMenuTracker.send(new HitBuilders.EventBuilder().setCategory("Options Menu").setAction("Settings") .setLabel("Show Settings").setValue(1).build()); Bundle settingsArgs = new Bundle(); // we don't do anything with this yet SettingsDialog settingsDlg = SettingsDialog.newInstance(settingsArgs); settingsDlg.show(getSupportFragmentManager(), "frg_show_settings"); return true; case R.id.action_donate: goToDonateScreen(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
private void startDilog() { AlertDialog.Builder myAlertDilog = new AlertDialog.Builder(GetAllVehicalDetails.this); myAlertDilog.setTitle("Upload picture option.."); myAlertDilog.setMessage("Take Photo"); myAlertDilog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() { @Override/*from w w w .jav a2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { Intent picIntent = new Intent(Intent.ACTION_GET_CONTENT, null); picIntent.setType("image/*"); picIntent.putExtra("return_data", true); startActivityForResult(picIntent, GALLERY_REQUEST); } }); myAlertDilog.setNegativeButton("Camera", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkPermission(Manifest.permission.CAMERA, GetAllVehicalDetails.this)) { openCameraApplication(); } else { requestPermission(GetAllVehicalDetails.this, new String[] { Manifest.permission.CAMERA }, REQUEST_ACESS_CAMERA); } } else { openCameraApplication(); } } }); myAlertDilog.show(); }
From source file:com.zlkj.dingdangwuyou.activity.CompanyInfoActivity.java
/** * ?//from w w w . jav a2 s .c o m */ private void showAvatarOption() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String[] items = new String[] { "?", "" }; builder.setTitle("").setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); switch (which) { case 0: // ? if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { String curTime = AppTool.dateFormat(System.currentTimeMillis(), "yyyyMMddHHmmss"); // ??? File imagePath = new File(Environment.getExternalStorageDirectory() + Const.APP_IMAGE_PATH); if (!imagePath.exists()) { imagePath.mkdirs(); } cameraFile = new File(imagePath.getPath(), curTime + ".jpg"); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)); startActivityForResult(intent, Const.REQUEST_CODE_CAMERA); } else { Toast.makeText(context, "???", Toast.LENGTH_SHORT) .show(); } break; case 1: // intent.setAction(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, Const.REQUEST_CODE_GALLERY); break; default: break; } } }); builder.show(); }
From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java
@Override public void onImageSelect(ScreenshotMechanismView screenshotMechanismView) { tempMechanismViewId = screenshotMechanismView.getMechanismViewIndex(); final Resources res = getResources(); final CharSequence[] items = { res.getString(R.string.supersede_feedbacklibrary_library_chooser_text), res.getString(R.string.supersede_feedbacklibrary_cancel_string) }; AlertDialog.Builder builder = new AlertDialog.Builder(FeedbackActivity.this); builder.setTitle(res.getString(R.string.supersede_feedbacklibrary_image_selection_dialog_title)); builder.setItems(items, new DialogInterface.OnClickListener() { @Override//w w w .j a v a 2 s. c om public void onClick(DialogInterface dialog, int item) { if (!items[item].equals(res.getString(R.string.supersede_feedbacklibrary_cancel_string))) { boolean result = Utils.checkSinglePermission(FeedbackActivity.this, PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, null, null, false); if (items[item].equals(res.getString(R.string.supersede_feedbacklibrary_photo_capture_text))) { userScreenshotChosenTask = res .getString(R.string.supersede_feedbacklibrary_photo_capture_text); if (result) { } } else if (items[item] .equals(res.getString(R.string.supersede_feedbacklibrary_library_chooser_text))) { userScreenshotChosenTask = res .getString(R.string.supersede_feedbacklibrary_library_chooser_text); if (result) { galleryIntent(); } } } else { dialog.dismiss(); } } }); builder.show(); }
From source file:com.zira.registration.DocumentUploadActivity.java
protected void selectImage() { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(DocumentUploadActivity.this); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override//from w ww .j ava 2 s.c o m public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { mCurrentPhotoPath = Util.createImageFile(); photoFile = new File(mCurrentPhotoPath); } catch (Exception ex) { // Error occurred while creating the File ex.printStackTrace(); } // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, 1); } } } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 2); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:fi.mikuz.boarder.gui.DropboxMenu.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_share: Thread thread = new Thread() { public void run() { Looper.prepare();/* w w w. j av a2 s. c o m*/ try { final ArrayList<String> boards = mCbla.getAllSelectedTitles(); if (!(mOperation == DOWNLOAD_OPERATION)) { mToastMessage = "Select 'Download' mode"; mHandler.post(mShowToast); } else if (boards.size() < 1) { mToastMessage = "Select boards to share"; mHandler.post(mShowToast); } else { String shareString = "I want to share some cool soundboards to you!\n\n" + "To use the boards you need to have Boarder for Android:\n" + ExternalIntent.mExtLinkMarket + "\n\n" + "Here are the boards:\n"; for (String board : boards) { shareString += board + " - " + mApi.createCopyRef("/" + board).copyRef + "\n"; } shareString += "\n\n" + "Importing a board:\n" + "1. Open Boarder'\n" + "2. Open Dropbox from menu in 'Soundboard Menu'\n" + "3. Open 'Import share' from menu\n" + "4. Copy a reference from above to textfield\n"; Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sharing boards"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(sharingIntent, "Share via")); } } catch (DropboxException e) { Log.e(TAG, "Unable to share", e); } } }; thread.start(); return true; case R.id.menu_import_share: LayoutInflater removeInflater = (LayoutInflater) DropboxMenu.this .getSystemService(LAYOUT_INFLATER_SERVICE); View importLayout = removeInflater.inflate(R.layout.dropbox_menu_alert_import_share, (ViewGroup) findViewById(R.id.alert_remove_sound_root)); AlertDialog.Builder importBuilder = new AlertDialog.Builder(DropboxMenu.this); importBuilder.setView(importLayout); importBuilder.setTitle("Import share"); final EditText importCodeInput = (EditText) importLayout.findViewById(R.id.importCodeInput); final EditText importNameInput = (EditText) importLayout.findViewById(R.id.importNameInput); importBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { t = new Thread() { public void run() { Looper.prepare(); try { mApi.addFromCopyRef(importCodeInput.getText().toString(), "/" + importNameInput.getText().toString()); mToastMessage = "Download the board from 'Download'"; mHandler.post(mShowToast); } catch (DropboxException e) { Log.e(TAG, "Unable to get shared board", e); } } }; t.start(); } }); importBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); importBuilder.show(); return true; } return super.onMenuItemSelected(featureId, item); }
From source file:au.org.intersect.faims.android.ui.activity.ShowModuleActivity.java
public void disableSync() { if (!activityData.isSyncEnabled()) return;/*from w w w .j av a 2 s . co m*/ if (syncStarted) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Stop Syncing"); builder.setMessage("Syncing is still in progress. Do you want to stop the sync?"); builder.setPositiveButton("Yes", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activityData.setSyncEnabled(false); syncStarted = false; stopSync(); } }); builder.setNegativeButton("No", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); } else { activityData.setSyncEnabled(false); stopSync(); } }