List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void onError(String error) { String message = "BG Geolocation caught a Javascript exception while running in background-thread:\n" .concat(error);// www . j a v a 2s .co m Log.e(TAG, message); // Show alert popup with js error if (isDebugging()) { playSound(68); AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity()); builder.setMessage(message).setCancelable(false).setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //do things } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:edu.pitt.gis.uniapp.UniApp.java
/** * Display an error dialog and optionally exit application. * * @param title/*from w ww.j a v a 2 s. co m*/ * @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:notused.Login.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login);//from ww w. j ava 2 s. co m txtEmail = (TextView) findViewById(R.id.email); txtPassword = (TextView) findViewById(R.id.password); btnLogin = (Button) findViewById(R.id.login); ckRememberMe = (CheckBox) findViewById(R.id.checkbox); txtForgotPassword = (TextView) findViewById(R.id.forgotPassword); txtSignUp = (TextView) findViewById(R.id.signUp); validator = new Validator(); config = new Config(Login.this); dbAdapter = new UserDBAdapter(this); baseUrl = "http://lawpavilionstore.com/android/login"; dbAdapter.open(DB_NAME); //TODO: remove drop table query dbAdapter.executeQuery("DROP TABLE IF EXISTS" + dbAdapter.TABLE_NAME + ";"); //dbAdapter.createUserTable(); Cursor cursor = dbAdapter.fetch("SELECT * from " + dbAdapter.TABLE_NAME); if (cursor != null) { //new user if (cursor.getCount() == 1) { String loggedOut = cursor.getString(cursor.getColumnIndex(dbAdapter.LOG_OUT)); if (loggedOut.equalsIgnoreCase("0")) { //User not looged out..continue String token = cursor.getString(cursor.getColumnIndex(dbAdapter.TOKEN)); Toast.makeText(Login.this, "Existing", Toast.LENGTH_SHORT).show(); Login.this.finish(); String set_up_status = cursor.getString(cursor.getColumnIndex(dbAdapter.SET_UP_STATUS)); if (set_up_status.equalsIgnoreCase("pending")) { Intent intent = new Intent(Login.this, Module.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else { Intent intent = new Intent(Login.this, Dashboard.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } else { //user has been forced to login.. SIGN_IN_TYPE = LOGGED_OUT_USER_TYPE; } } else { //New user account.. SIGN_IN_TYPE = NEW_USER_TYPE; } } else { Toast.makeText(Login.this, "DB error", Toast.LENGTH_SHORT).show(); //Do something here } dbAdapter.close(); btnLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _email = txtEmail.getText().toString().trim(); _password = txtPassword.getText().toString().trim(); boolean isFieldSet = true; if (!validator.isValidEmail(_email)) { txtEmail.setError(Validator.emailErrorMessage); isFieldSet = false; } if (validator.isEmpty(_password)) { txtPassword.setError(Validator.defaultErrorMessage); isFieldSet = false; } Toast.makeText(Login.this, "Ready for Async Task", Toast.LENGTH_SHORT).show(); if (isFieldSet) { if (config.isConnectingToInternet()) { AsyncLogin asyncLogin = new AsyncLogin(); asyncLogin.execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(Login.this); builder.setTitle("Error"); builder.setMessage("Oops! Something went wrong!\n\nplease check your internet connection") .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AsyncLogin asyncLogin = new AsyncLogin(); asyncLogin.execute(); } }); AlertDialog dialog = builder.create(); dialog.show(); } } else { return; } } }); txtForgotPassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Login.this, ForgotPassword.class); startActivity(intent); } }); txtSignUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Login.this, SignUp.class); startActivity(intent); } }); }
From source file:com.flipzu.flipzu.Player.java
private void showFinishedDialog() { AlertDialog aDialog;//from www . j a va 2 s . c o m AlertDialog.Builder builder; builder = new AlertDialog.Builder(this); builder.setMessage("FlipZu Finished").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); aDialog = builder.create(); Dialog dialog = aDialog; dialog.show(); }
From source file:org.webpki.mobile.android.proxy.BaseProxyActivity.java
public void conditionalAbort(final String message) { final BaseProxyActivity instance = this; AlertDialog.Builder alert_dialog = new AlertDialog.Builder(this).setMessage(getAbortString()) .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // The user decided that this is not what he/she wants... dialog.cancel();// www. j av a2s . c o m user_aborted = true; abortTearDown(); if (abort_url == null) { instance.finish(); } else { launchBrowser(abort_url); } } }); alert_dialog.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // The user apparently changed his/her mind and wants to continue... dialog.cancel(); if (message != null && progress_display != null) { progress_display = null; showHeavyWork(message); } } }); // Create and show alert dialog alert_dialog.create().show(); }
From source file:dtu.ds.warnme.app.dialog.ReportDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_report, null); builder.setView(view);/*from w ww . ja v a 2s .co m*/ builder.setTitle(R.string.report); builder.setPositiveButton(R.string.report, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing do to here } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing do to here } }); progressView = view.findViewById(R.id.dialog_report_progress); formView = view.findViewById(R.id.dialog_report_form); accidentRdBtn = (RadioButton) view.findViewById(R.id.dialog_report_form_radio_button_event_type_accident); policeRdBtn = (RadioButton) view.findViewById(R.id.dialog_report_form_radio_button_event_type_police); speedCameraRdBtn = (RadioButton) view .findViewById(R.id.dialog_report_form_radio_button_event_type_speed_camera); noteEditText = (EditText) view.findViewById(R.id.dialog_report_form_edit_text_note); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String note = noteEditText.getText().toString(); Location location = (Location) getArguments().get(MainActivity.KEY_CURRENT_LOCATION); Event event = new Event(); event.setEventType(getEventType()); event.setLatitude(location.getLatitude()); event.setLongitude(location.getLongitude()); event.setBearing((180 + location.getBearing()) % 360); event.setNote(note); RestClientHolder.getRestClient().addEvent(dialog.getContext(), event, new AsyncHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Log.e(TAG, "Reporting failed. [statusCode = " + statusCode + ", error=" + error + "]"); listener.onReportFailed(); Toast.makeText(dialog.getContext(), R.string.report_failed, Toast.LENGTH_LONG).show(); } @Override public void onFinish() { positiveButton.setEnabled(true); UiUtilities.fadeInFadeOut(formView, progressView); } @Override public void onStart() { positiveButton.setEnabled(false); UiUtilities.fadeInFadeOut(progressView, formView); } @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i(TAG, "Reporting successful. [statusCode = " + statusCode + "]"); dialog.dismiss(); listener.onReportSuccessful(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RestClientHolder.getRestClient().cancelRequests(dialog.getOwnerActivity(), true); dialog.dismiss(); listener.onAbort(); } }); } }); return dialog; }
From source file:net.reichholf.dreamdroid.activities.ServiceListActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { mCurrentItem = mMapList.get(position); final String ref = mCurrentItem.getString(Event.SERVICE_REFERENCE); final String nam = mCurrentItem.getString(Event.SERVICE_NAME); final String title = mCurrentItem.getString(Event.EVENT_TITLE); if (isBouquetReference(ref)) { if (!isListTaskRunning()) { mIsBouquetList = true;// w w w.j av a 2 s .c o m // Second hierarchy level -> we get a List of Services now if (isBouquetReference(mReference)) { mIsBouquetList = false; } ExtendedHashMap map = new ExtendedHashMap(); map.put(Event.SERVICE_REFERENCE, String.valueOf(mReference)); map.put(Event.SERVICE_NAME, String.valueOf(mName)); mHistory.add(map); mReference = ref; mName = nam; reload(); } else { showToast(getText(R.string.wait_request_finished)); } } else { if (mPickMode) { ExtendedHashMap map = new ExtendedHashMap(); map.put(Event.SERVICE_REFERENCE, ref); map.put(Event.SERVICE_NAME, nam); Intent intent = new Intent(); intent.putExtra(sData, map); setResult(RESULT_OK, intent); finish(); } else { CharSequence[] actions = { getText(R.string.current_event), getText(R.string.browse_epg), getText(R.string.zap), getText(R.string.similar), getText(R.string.stream) }; AlertDialog.Builder adBuilder = new AlertDialog.Builder(this); adBuilder.setTitle(getText(R.string.pick_action)); adBuilder.setItems(actions, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: removeDialog(DIALOG_EPG_ITEM_ID); showDialog(DIALOG_EPG_ITEM_ID); break; case 1: openEpg(ref, nam); break; case 2: zapTo(ref); break; case 3: openSimilar(title); break; case 4: streamService(ref); break; } } }); AlertDialog alert = adBuilder.create(); alert.show(); } } }
From source file:mp.paschalis.RequestActivity.java
/** * Replies to request of user//from w w w . j a va 2s . c o m */ private void hButtonReplyRequest() { buttonHybrid.setText(R.string.reply); buttonHybrid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(RequestActivity.this); builder.setIcon(R.drawable.ic_menu_info_details); builder.setTitle(R.string.replyToRequest); builder.setItems(R.array.ArrayRequestReply, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { LentBookActivity.DataClassLentABook d = new LentBookActivity.DataClassLentABook(); d.destinationUser = dataClassActivities.username; d.isbn = dataClassActivities.book.isbn; d.answer = "0"; if (item == 0) d.answer = "1"; new AsyncTaskReplyToRequest().execute(d); } }); AlertDialog alert = builder.create(); alert.show(); } }); }
From source file:org.uoyabause.android.YabauseHandler.java
@Override public Dialog onCreateDialog(int id, Bundle args) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(args.getString("message")).setCancelable(false) .setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Yabause.this.finish(); }/*from www . j av a 2s .com*/ }).setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); return alert; }
From source file:com.cloudant.todo.TodoActivity.java
public Dialog createNewTaskDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View v = this.getLayoutInflater().inflate(R.layout.dialog_new_task, null); final EditText description = (EditText) v.findViewById(R.id.new_task_desc); // Check description is present, if so add a task otherwise show an error DialogInterface.OnClickListener positiveClick = new DialogInterface.OnClickListener() { @Override//from w w w.j ava 2s .c om public void onClick(DialogInterface dialog, int id) { if (description.getText().length() > 0) { createNewTask(description.getText().toString()); description.getText().clear(); } else { Toast.makeText(getApplicationContext(), R.string.task_not_created, Toast.LENGTH_LONG).show(); } } }; DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }; builder.setView(v).setTitle(R.string.new_task).setPositiveButton(R.string.create, positiveClick) .setNegativeButton(R.string.cancel, negativeClick); final AlertDialog d = builder.create(); // Enable "Create" button when the description has some characters final TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }; d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); description.addTextChangedListener(textWatcher); } }); return d; }