List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:org.openhab.habdroid.ui.OpenHABWidgetListFragment.java
private void showAlertDialog(String alertMessage) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(alertMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { }//from w w w. j a v a 2s . c o m }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void semesterPicker(final StringCallback stringCallback) { final String[] items = { "1", "2", "Vacation 1", "3", "4", "Vacation 2", "5", "6", "Vacation 3", "7", "8", "Vacation 4", "9", "10", "Vacation 5", "11", "12", "Vacation 6", "13", "14", "15" }; AlertDialog.Builder builder = new AlertDialog.Builder(baseContext); builder.setCancelable(true);// w w w . j av a2s. c o m builder.setTitle("Select a Semester"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { stringCallback.onFinish(items[which]); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:de.grobox.blitzmail.SendActivity.java
private void showError(String text) { // close notification first mNotifyManager.cancel(0);/*from w ww . j av a 2s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + " - " + getString(R.string.error)); builder.setMessage(text); builder.setIcon(android.R.drawable.ic_dialog_alert); // Add the buttons builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked Cancel button, close this Activity finish(); } }); // Create and show the AlertDialog AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
From source file:it.evilsocket.dsploit.core.System.java
public static boolean checkNetworking(final Activity current) { if (Network.isWifiConnected(mContext) == false) { AlertDialog.Builder builder = new AlertDialog.Builder(current); builder.setCancelable(false);/*from w ww .j av a 2 s . co m*/ builder.setTitle("Error"); builder.setMessage("WiFi connectivity went down."); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Bundle bundle = new Bundle(); bundle.putBoolean(WifiScannerActivity.CONNECTED, false); Intent intent = new Intent(); intent.putExtras(bundle); current.setResult(Activity.RESULT_OK, intent); current.finish(); } }); AlertDialog alert = builder.create(); alert.show(); return false; } return true; }
From source file:com.app.swaedes.swaedes.MapPage.java
public void sitesPositionsFetchAlert() { AlertDialog.Builder localBuilder = new AlertDialog.Builder(MapPage.this); localBuilder.setMessage("Get location of other sites? (if no only current location will be displayed)") .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramDialogInterface, int paramInt) { MapPage.this.getJsonMarkers(); }//from w w w . j av a 2 s . co m }); localBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramDialogInterface, int paramInt) { paramDialogInterface.cancel(); } }); localBuilder.create().show(); }
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.PlayAllAudioAction.java
public void onAct(Context context, DbEntryHandler objType, DbObj obj) { DBHelper helper = DBHelper.getGlobal(context); this.context = context; JSONObject objData = obj.getJson();/*from www . ja va 2s.c om*/ //TODO: this cursor really need to be closed somewhere!!! it may be but its sketchy //TODO: holy frickin hell its sketch... slutty code, plus it pulls the full body in as well //it should maybe load an objid list and then fetch each voice obj individually. String query = DbObject.FEED_NAME + "= ? AND " + DbObject.TYPE + "='voice' AND " + DbObject._ID + " >= (SELECT " + DbObject._ID + " FROM " + DbObject.TABLE + " WHERE " + DbObject.FEED_NAME + "= ? AND " + DbObject.TYPE + "='voice' AND " + DbObject.SEQUENCE_ID + "= ? AND " + DbObject.TIMESTAMP + "= ?)"; String[] queryParams = new String[] { objData.optString("feedName"), objData.optString("feedName"), objData.optString("sequenceId"), objData.optString("timestamp") }; c = helper.getReadableDatabase().query(DbObject.TABLE, null, query, queryParams, null, null, DbObject._ID + " ASC"); c.moveToFirst(); /*while(!c.isAfterLast()) { Log.w("PlayAllAudioAction", c.getString(c.getColumnIndex(DbObject.JSON))); c.moveToNext(); }*/ playNextSong(); //c.close(); Log.w("PlayAllAudioAction", c.getCount() + " rows"); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage("Now Playing Voice Messages").setCancelable(false).setNegativeButton("Stop Playing", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); c.moveToLast(); c.moveToNext(); mp.stop(); mp.release(); } }); alert = builder.create(); alert.show(); }
From source file:com.phonegap.Notification.java
/** * Builds and shows a native Android alert with given Strings * @param message The message the alert should display * @param title The title of the alert * @param buttonLabel The label of the button * @param callbackId The callback id/*from ww w. j a v a 2s . c o m*/ */ public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) { final PhonegapActivity ctx = this.ctx; final Notification notification = this; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(ctx); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); notification.success(new PluginResult(PluginResult.Status.OK, 0), callbackId); } }); dlg.create(); dlg.show(); }; }; this.ctx.runOnUiThread(runnable); }
From source file:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java
private void showAlertDialog(String alertMessage) { AlertDialog.Builder builder = new AlertDialog.Builder(OpenHABRoomSettingActivity.this); builder.setMessage(alertMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { }//from w w w . j a va2 s . c o m }); AlertDialog alert = builder.create(); alert.show(); }
From source file:edu.usf.cutr.opentripplanner.android.tasks.OTPGeocoding.java
protected void onCancelled(Long result) { if (activity.get() != null) { AlertDialog.Builder geocoderAlert = new AlertDialog.Builder(activity.get()); geocoderAlert.setTitle(R.string.geocoder_results_title).setMessage(R.string.geocoder_no_results_message) .setCancelable(false).setPositiveButton(context.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { }//from w ww . j a v a 2s. c om }); AlertDialog alert = geocoderAlert.create(); alert.show(); } Log.e(TAG, "No geocoding processed!"); }
From source file:com.doomy.decode.ResultDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater mLayoutInflater = LayoutInflater.from(getActivity()); View mView = mLayoutInflater.inflate(R.layout.view_result, null); TextView mTextViewFormat = (TextView) mView.findViewById(R.id.textViewFormat); TextView mTextViewContent = (TextView) mView.findViewById(R.id.textViewContent); if (mTitle.equals("EAN 13") && mMessage.startsWith("978")) { GetResponseTask mGetResponseTask = new GetResponseTask(); mGetResponseTask.execute(mMessage); try {/*w w w. j a v a 2 s . c o m*/ if (mGetResponseTask.get().equals("")) { mTitle = "ISBN"; mTextViewContent.setText(mMessage); } else { mTitle = "ISBN"; mMessage = mGetResponseTask.get(); SpannableString mSpan = new SpannableString(mMessage); mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0); mTextViewContent.setText(mSpan); mTextViewContent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createURLIntent(makeURLSearch(mMessage)); } }); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } else if (mTitle.equals("ISBN")) { if (!mMessage.startsWith("978")) { SpannableString mSpan = new SpannableString(mMessage); mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0); mTextViewContent.setText(mSpan); mTextViewContent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createURLIntent(makeURLSearch(mMessage)); } }); } else { mTextViewContent.setText(mMessage); } } else if (mMessage.startsWith("www") || mMessage.startsWith("http://") || mMessage.startsWith("https://")) { SpannableString mSpan = new SpannableString(mMessage); mSpan.setSpan(new UnderlineSpan(), 0, mMessage.length(), 0); mTextViewContent.setText(mSpan); mTextViewContent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createURLIntent(mMessage); } }); } else { mTextViewContent.setText(mMessage); } if (mKey) { SimpleDateFormat mDateFormat = new SimpleDateFormat("dd/MM/yyyy-HH:mm"); String mDate = mDateFormat.format(new Date()); Scan mScan = new Scan(mTitle, mMessage, mDate); mDB.addOne(mScan); } mTextViewFormat.setText(mTitle); AlertDialog.Builder mAlertBuilder = new AlertDialog.Builder(getActivity(), Utils.setThemeDialog()); mAlertBuilder.setTitle(getString(R.string.info)).setView(mView).setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (mListener != null) { mListener.onDialogPositiveClick(ResultDialogFragment.this); } } }); return mAlertBuilder.create(); }