List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java
private Dialog removeDialog(Context context) { LayoutInflater inflater = LayoutInflater.from(context); final View textEntryView = inflater.inflate(R.layout.remove_id, null); final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local); rm_check.setText(R.string.remove_local); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setView(textEntryView);/*from ww w. j a v a 2s . c o m*/ builder.setCancelable(false); builder.setTitle(R.string.assign_remove_title); builder.setMessage(R.string.remove_msg); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub cleanUp(ctx); cancelAlarms(ctx); // remove local file, if checked Log.d(TAG, "is checked " + rm_check.isChecked()); if (rm_check.isChecked()) { deleteDirectory(Util.PHONE_BASE_PATH); } setHints(); finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); return builder.create(); }
From source file:com.cypress.cysmart.RDKEmulatorView.MicrophoneEmulatorFragment.java
/** * Method to display a custom alert.//w w w. ja v a 2 s .c o m * Option for entering the google key in the method for voice to * text conversion */ private void showCustumAlert(String storedKey, boolean changeNeeded) { LayoutInflater li = LayoutInflater.from(getActivity()); View promptsView = li.inflate(R.layout.api_key_dialog_alert, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); // set api_key_dialog_alert.xml to alertdialog builder alertDialogBuilder.setView(promptsView); //User input Edittext final EditText userInput = (EditText) promptsView.findViewById(R.id.custom_alert_user_input); if (changeNeeded) { userInput.setText(storedKey); } // set dialog message alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // get user input and set it to sharedpreferecne Logger.i("userInput.getText()--->" + userInput.getText()); Utils.setStringSharedPreference(getActivity(), Constants.PREF_GOOGLE_API_KEY, userInput.getText().toString()); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); }
From source file:com.fvd.nimbus.BrowseActivity.java
void messageBox(String msg) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle(msg);//w ww.j a v a 2 s. c o m dialog.setPositiveButton("OK", null); dialog.setCancelable(true); dialog.create().show(); }
From source file:net.hockeyapp.android.internal.CheckUpdateTask.java
private void showDialog(final JSONArray updateInfo) { if (getCachingEnabled()) { VersionCache.setVersionInfo(activity, updateInfo.toString()); }//from w w w.ja va 2s .c o m if ((activity == null) || (activity.isFinishing())) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(Strings.get(listener, Strings.UPDATE_DIALOG_TITLE_ID)); if (!mandatory) { builder.setMessage(Strings.get(listener, Strings.UPDATE_DIALOG_MESSAGE_ID)); builder.setNegativeButton(Strings.get(listener, Strings.UPDATE_DIALOG_NEGATIVE_BUTTON_ID), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { cleanUp(); } }); builder.setPositiveButton(Strings.get(listener, Strings.UPDATE_DIALOG_POSITIVE_BUTTON_ID), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (getCachingEnabled()) { VersionCache.setVersionInfo(activity, "[]"); } if ((UpdateManager.fragmentsSupported()) && (UpdateManager.runsOnTablet(activity))) { showUpdateFragment(updateInfo); } else { startUpdateIntent(updateInfo, false); } } }); builder.create().show(); } else { Toast.makeText(activity, Strings.get(listener, Strings.UPDATE_MANDATORY_TOAST_ID), Toast.LENGTH_LONG) .show(); startUpdateIntent(updateInfo, true); } }
From source file:com.abc.driver.TruckActivity.java
private void doCrop() { Log.d(TAG, "doCrop()"); final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = this.getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Log.d(TAG, " Crop activity is not found. List size is zero."); Bitmap tmpBmp = BitmapFactory.decodeFile(imageUri.getPath(), null); trcukLicenseBmp = Bitmap.createScaledBitmap(tmpBmp, IMAGE_WIDTH, IMAGE_HEIGHT, false); mTLPiv.setImageBitmap(trcukLicenseBmp); isPortraitChanged = true;/*from ww w.ja va 2 s.c o m*/ Log.d(TAG, "set bitmap"); return; } else { Log.d(TAG, "found the crop activity."); intent.setData(imageUri); intent.putExtra("outputX", IMAGE_WIDTH); intent.putExtra("outputY", IMAGE_HEIGHT); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("return-data", true); if (size == 1) { Log.d(TAG, "Just one as choose it as crop activity."); Intent i = new Intent(intent); ResolveInfo res = list.get(0); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); startActivityForResult(i, CellSiteConstants.CROP_PICTURE); } else { Log.d(TAG, "More that one activity for crop is found . will chooose one"); for (ResolveInfo res : list) { final CropOption co = new CropOption(); co.title = getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo); co.icon = getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo); co.appIntent = new Intent(intent); co.appIntent .setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); cropOptions.add(co); } CropOptionAdapter adapter = new CropOptionAdapter(getApplicationContext(), cropOptions); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Crop App"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { startActivityForResult(cropOptions.get(item).appIntent, CellSiteConstants.CROP_PICTURE); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { // @Override public void onCancel(DialogInterface dialog) { if (imageUri != null) { getContentResolver().delete(imageUri, null, null); imageUri = null; isPortraitChanged = false; } } }); AlertDialog alert = builder.create(); alert.show(); } } }
From source file:com.phonegap.DroidGap.java
/** * Display an error dialog and optionally exit application. * //w ww.j av a 2s. co m * @param title * @param message * @param button * @param exit */ public void displayError(final String title, final String message, final String button, final boolean exit) { final DroidGap me = this; me.runOnUiThread(new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(me); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setPositiveButton(button, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (exit) { me.finish(); } } }); dlg.create(); dlg.show(); } }); }
From source file:gr.scify.newsum.ui.ViewActivity.java
private void Copy() { // TextView tx = (TextView) findViewById(R.id.textView1); TextView title = (TextView) findViewById(R.id.title); String sdtitle = title.getText().toString(); // String copytext = tx.getText().toString(); String alphaAndDigits = sdtitle.replaceAll("[^\\p{L}\\p{N}]", " "); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); // track the copy to SD event if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Save to SD", title.getText().toString(), 0l); }/* ww w. j a v a 2 s . c o m*/ if (isSDPresent) { File folder = new File(Environment.getExternalStorageDirectory() + "/NewSum"); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { // Do something on success } else { // Do something else on failure } File logFile = new File(folder, alphaAndDigits + ".txt"); // File logFile = new // File(Environment.getExternalStorageDirectory().toString(), // alphaAndDigits+".txt"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } BufferedWriter output = null; try { output = new BufferedWriter(new FileWriter(logFile)); } catch (IOException e) { e.printStackTrace(); } try { output.write(pText); } catch (IOException e) { e.printStackTrace(); } try { output.close(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.save_massage); builder.setMessage(logFile.getPath()); builder.setPositiveButton(getResources().getText(R.string.ok).toString(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog a = builder.create(); a.show(); } catch (IOException e) { e.printStackTrace(); } } else { Toast.makeText(ViewActivity.this, R.string.check_sd, Toast.LENGTH_SHORT).show(); } }
From source file:com.snt.bt.recon.activities.MainActivity.java
private void buildAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Your GPS is currently disabled, do you want to manually enable it?") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/* w ww . j a v a 2 s . c o m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); //close app finishAffinity(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java
private Dialog onCreatePasswdDialog() { final AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.setPositiveButton(R.string.ok, new OnClickListener() { @Override/*www . j a v a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { if (dialog instanceof AlertDialog) { final AlertDialog dlg = (AlertDialog) dialog; final EditText passwd = (EditText) dlg.findViewById(R.id.dialog_text); if (passwd == null) { return; } mPasswd = passwd.getText().toString(); updateMessage(R.string.login_google, null); new Thread(new Runnable() { public void run() { login(); } }).start(); } } }); ab.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); ab.setTitle("Password for " + mAccount.name); final LayoutInflater inflator = getLayoutInflater(); ab.setView(inflator.inflate(R.layout.passwd, null)); return ab.create(); }
From source file:com.nps.micro.view.TestsSectionFragment.java
private void createDeviceChooser(View rootView, final Button runButton) { availableDevicesListView = (ListView) rootView.findViewById(R.id.availableDevicesListView); availableDevicesAdapter = new ArrayAdapter<String>(getActivity(), R.layout.text_view, devicesList); availableDevicesListView.setAdapter(availableDevicesAdapter); availableDevicesListView.setTextFilterEnabled(true); availableDevicesListView.setOnItemClickListener(new OnItemClickListener() { @Override/*from w ww .j a v a2 s .c o m*/ public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { String item = (String) parent.getItemAtPosition(position); selectedDevices.add(ensureUniqueItem(item)); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); setListViewHeightBasedOnChildren(selectedDevicesListView); updateModelSelectedDevices(); } private String ensureUniqueItem(String item) { if (selectedDevices.contains(item)) { return ensureUniqueItem(item + "'"); } else { return item; } } }); availableDevicesListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, final View view, int position, long id) { view.setBackgroundColor(Color.CYAN); final String item = (String) parent.getItemAtPosition(position); final String msg = getResources().getString(R.string.ping_device_info); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.ping_device_title).setMessage(String.format(msg, item)) .setPositiveButton(R.string.ping, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { view.setBackgroundColor(Color.BLACK); if (listener != null) { listener.pingDevice(item); } dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { view.setBackgroundColor(Color.BLACK); dialog.dismiss(); } }); builder.create().show(); return true; } }); setListViewHeightBasedOnChildren(availableDevicesListView); selectedDevicesListView = (DynamicListView) rootView.findViewById(R.id.selectedDevicesListView); selectedDevicesListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setListItems(selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); selectedDevicesListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { final String item = (String) parent.getItemAtPosition(position); selectedDevices.remove(item); selectedDevicesAdapter = new StableArrayAdapter(getActivity(), R.layout.text_view, selectedDevices); selectedDevicesListView.setAdapter(selectedDevicesAdapter); setListViewHeightBasedOnChildren(selectedDevicesListView); updateModelSelectedDevices(); } }); selectedDevicesListView.setOnTouchListener(new ListView.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: v.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: v.getParent().requestDisallowInterceptTouchEvent(false); break; } v.onTouchEvent(event); return true; } }); setListViewHeightBasedOnChildren(selectedDevicesListView); }