List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
private void selectImage() { final CharSequence[] items = { "Take Photo", "Choose from Library", "Cancel" }; android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this); builder.setTitle("Add Photo!"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override/* w w w . j av a 2 s .c o m*/ public void onClick(DialogInterface dialog, int item) { boolean result = UtilNew.checkPermission(RegisterActivity.this); if (items[item].equals("Take Photo")) { userChoosenTask = "Take Photo"; if (result) cameraIntent(); } else if (items[item].equals("Choose from Library")) { userChoosenTask = "Choose from Library"; if (result) galleryIntent(); } else if (items[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java
public void useBeacon(int position) { final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ?"); alertDialog.setMessage("? ? ?"); alertDialog.setIcon(R.drawable.alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateEvent("BEACON_USE"); UseBeacon useBeacon = new UseBeacon(); useBeacon.execute("http://125.131.73.198:3000/beaconUse", beaconmac); }//from w w w . j a va 2 s .com }); // Setting Negative "NO" Button alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java
private void successDialog(int i) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); if (i == 2 || i == 3) { alertDialog.setTitle(" ? "); alertDialog.setMessage("? ? ??"); } else if (i == 1) { alertDialog.setTitle(" "); alertDialog.setMessage("? ? ?"); } else if (i == 4) { alertDialog.setTitle(" "); alertDialog.setMessage("? ? ?"); }//w w w . jav a2 s . c o m alertDialog.setIcon(R.drawable.ic_dialog_alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke YES event dialog.cancel(); getMyBeaconList(); } }); alertDialog.show(); }
From source file:com.googlecode.CallerLookup.Main.java
public void doRemove() { final Context context = this; final String name = mLookup.getSelectedItem().toString(); AlertDialog.Builder confirm = new AlertDialog.Builder(context); confirm.setTitle(R.string.RemoveTitle); confirm.setMessage(R.string.RemoveMessage); confirm.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @SuppressWarnings("unchecked") @Override//from ww w .j a va 2 s.co m public void onClick(DialogInterface dialog, int which) { removeUserLookupEntry(name); doCustomize(); ArrayAdapter<CharSequence> adapter = (ArrayAdapter<CharSequence>) mLookup.getAdapter(); adapter.remove(name); } }); confirm.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); confirm.show(); }
From source file:edu.pitt.gis.uniapp.UniApp.java
/** * Display an error dialog and optionally exit application. * * @param title/* w w w . j a va 2 s .c om*/ * @param message * @param button * @param exit */ public void displayError(final String title, final String message, final String button, final boolean exit) { final UniApp me = this; me.runOnUiThread(new Runnable() { public void run() { try { 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.endActivity(); } } }); dlg.create(); dlg.show(); } catch (Exception e) { finish(); } } }); }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void onRemoveClick(View view) { try {//from w ww.j av a 2s .com Toast.makeText(this, item, Toast.LENGTH_SHORT).show(); String[] remove = { "rm", "-rf", irpath + item }; try { Process p = Runtime.getRuntime().exec(remove); Log.i("rm", "Waiting... " + irpath + item); p.waitFor(); Log.i("rm", "Done! " + irpath + item); } catch (Exception e) { Log.e("rm", "Failed! " + irpath + item); e.printStackTrace(); } spinner = ((Spinner) findViewById(R.id.spinner)); localArrayList1 = new ArrayList(); localArrayList1.remove(item); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, localArrayList1); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.done)); builder.setMessage(getString(R.string.done_removing) + " " + item + " " + getString(R.string.files)); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); } catch (NullPointerException ex) { ex.printStackTrace(); AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.error)); adb.setMessage(getString(R.string.you_need_to_select)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb.show(); } }
From source file:com.meycup.ducksound.BackgroundSearch.java
@Override protected void onPostExecute(final String[][] strings) { if (strings[0][0].equals("error_on_search")) { if (strings[0][1].equals("")) { tv.setVisibility(View.VISIBLE); listView.setAdapter(null);//from www . j a va2 s .c o m } else { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle("Ocorreu um erro!"); alert.setMessage(strings[0][1]); alert.setPositiveButton("Tentar novamente", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BackgroundSearch research = new BackgroundSearch(context, listView, play_bar, tv); research.execute(search); dialog.dismiss(); } }); alert.setNegativeButton("Sair", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); System.exit(0); } }); alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); } } else { if (tv != null) { tv.setVisibility(View.INVISIBLE); } int count = 0; for (int i = 0; i < strings[0].length; i++) { if (strings[0][i] != null) { count++; } } ListAdapter adp = new ListAdapter(context, strings, new String[count]); listView.setAdapter(adp); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (strings[position + 1][6].equals("true")) { try { if (player != null) { player.stop(); player = new Player(play_bar, strings[position + 1][2], strings[0][position], (!strings[position + 1][4].equals("null")) ? strings[position + 1][4] : strings[position + 1][3], true); } else { player = new Player(play_bar, strings[position + 1][2], strings[0][position], (!strings[position + 1][4].equals("null")) ? strings[position + 1][4] : strings[position + 1][3], true); } } catch (IOException e) { e.printStackTrace(); } } else { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setMessage("Desculpe, no possvel reproduzir essa msica, escolha outra."); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); } } }); } listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (strings[position + 1][6].equals("true")) { File dir = new File(Environment.getExternalStorageDirectory() + "/Ducksound"); if (!dir.exists()) { dir.mkdirs(); } final DownloadManager DM = (DownloadManager) context.getSystemService(context.DOWNLOAD_SERVICE); String download_url; if (strings[position + 1][0].equals("true")) { download_url = strings[position + 1][5] + "?client_id=" + MainActivity.CLIENT_ID; } else { download_url = "http://188.138.17.231/~krafta/dow.php?url=" + strings[position + 1][2] + "?client_id=" + MainActivity.CLIENT_ID + "&name=" + URLEncoder.encode(strings[0][position] + "(Ducksound)"); } Uri uri = Uri.parse(download_url.replace("https://", "http://")); final DownloadManager.Request request = new DownloadManager.Request(uri); request.setAllowedNetworkTypes( DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE) .setAllowedOverRoaming(false).setTitle(strings[0][position]) .setDestinationInExternalPublicDir("/Ducksound", strings[0][position].replace(" ", "_").replace(",", "_").replace("", "c") .replace("'", "_") + " (" + context.getResources().getString(R.string.app_name) + ").mp3"); AlertDialog.Builder download = new AlertDialog.Builder(context); download.setTitle("Baixar \"" + strings[0][position] + "\"?"); download.setMessage("Tem certeza que deseja baixar essa msica?\nEla ser salva em " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/Ducksound"); download.setPositiveButton("Baixar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { DM.enqueue(request); dialogInterface.dismiss(); } }); download.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).show(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setMessage("Desculpe, no possvel baixar essa msica, escolha outra."); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); } return true; } }); progress.hide(); }
From source file:arc.noaa.weather.activities.MainActivity.java
private void showLocationSettingsDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle(R.string.location_settings); alertDialog.setMessage(R.string.location_settings_message); alertDialog.setPositiveButton(R.string.location_settings_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent);// w w w . j a v a 2 s . co m } }); alertDialog.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Reset internal Logs./* www. ja v a2 s . c o m*/ */ private void resetDataDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.reset_data_); builder.setMessage(R.string.reset_data_hint); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Preferences.this.resetData(DataProvider.TYPE_CALL); Preferences.this.resetData(DataProvider.TYPE_SMS); Preferences.this.resetData(DataProvider.TYPE_MMS); } }); builder.setNeutralButton(R.string.reset_data_data_, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Preferences.this.resetData(-1); } }); builder.setNegativeButton(android.R.string.no, null); builder.show(); }