@Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); int result = 0; try { result = Integer.valueOf(response.getString("result")); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (result == 1 && statusCode == 200) { AlertDialog.Builder builder = new Builder(E8_ResetPwdActivity.this); builder.setTitle("修改成功"); builder.setNegativeButton( "确认", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); } }); builder.create().show(); } else { Log.i("reset_pwd", response.toString()); try { String message = response.getString("message"); AlertDialog.Builder builder = new Builder(E8_ResetPwdActivity.this); builder.setTitle(message); builder.setNegativeButton( "确认", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); } }); builder.create().show(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
@Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); int result = 0; try { result = Integer.valueOf(response.getString("result")); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (result == 1 && statusCode == 200) { loadingPDialog.dismiss(); AlertDialog.Builder builder = new Builder(getActivity()); builder.setTitle("签到成功"); builder.setNegativeButton( "确认", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { profile_check.setImageResource(R.drawable.profile_checked); HttpUtils.refreshUserInfo(res_refresh); } }); builder.create().show(); } else { loadingPDialog.dismiss(); String message = ""; try { message = response.getString("message"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } AlertDialog.Builder builder = new Builder(getActivity()); builder.setTitle(message); builder.setNegativeButton( "确认", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {} }); builder.create().show(); Log.i("check_fail", response.toString()); } }
private AlertDialog showDialog( final Context context, final SharedPreferences.Editor editor, final String packageName, final long firstLaunchTime) { final AlertDialog.Builder rateDialog = new AlertDialog.Builder(context); rateDialog.setTitle(mText_title); rateDialog.setMessage(mText_explanation); rateDialog.setNeutralButton( mText_buttonLater, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { buttonLaterClick(editor, dialog, firstLaunchTime); } }); if (Build.VERSION.SDK_INT < 14) { rateDialog.setPositiveButton( mText_buttonNow, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { buttonNowClick(editor, dialog, context); } }); rateDialog.setNegativeButton( mText_buttonNever, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { buttonNeverClick(editor, dialog); } }); } else { rateDialog.setPositiveButton( mText_buttonNever, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { buttonNeverClick(editor, dialog); } }); rateDialog.setNegativeButton( mText_buttonNow, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { buttonNowClick(editor, dialog, context); } }); } return rateDialog.show(); }
@Override public void onPrepareDialogBuilder(final AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); prefs = getSharedPreferences(); if (prefs == null) return; final int length = mKeys.length; for (int i = 0; i < length; i++) { mValues[i] = prefs.getBoolean(mKeys[i], mDefaultValues[i]); } builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, null); builder.setMultiChoiceItems(mNames, mValues, this); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { new Thread() { @Override public void run() { Dialog dialog = null; while (dialog == null) { dialog = getDialog(); if (dialog != null) { final Message msg = new Message(); msg.obj = dialog; mDialogWorkaroundHandler.sendMessage(msg); } try { sleep(50L); } catch (final InterruptedException e) { } } } }.start(); } }
/** 显示版本更新通知对话框 */ private void showNoticeDialog() { AlertDialog.Builder builder = new Builder(mContext); builder.setTitle("软件版本更新"); builder.setMessage(updateMsg); builder.setPositiveButton( "立即更新", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); showDownloadDialog(); } }); builder.setNegativeButton( "以后再说", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); stopSelf(); } }); noticeDialog = builder.create(); noticeDialog.setCanceledOnTouchOutside(false); noticeDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); noticeDialog.show(); }
/** * 发送App异常崩溃报告 * * @param cont * @param crashReport */ public static void sendAppCrashReport(final Context cont, final String crashReport) { AlertDialog.Builder builder = new AlertDialog.Builder(cont); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(R.string.app_error); builder.setMessage(R.string.app_error_message); builder.setPositiveButton( R.string.submit_report, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // 发送异常报告 Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); // 模拟器 // i.setType("message/rfc822") ; //真机 i.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"}); i.putExtra(Intent.EXTRA_SUBJECT, "星宝宝Android客户端 - 错误报告"); i.putExtra(Intent.EXTRA_TEXT, crashReport); cont.startActivity(Intent.createChooser(i, "发送错误报告")); Log.i("Exception Log", crashReport); // 退出 AppManager.getAppManager().AppExit(cont); } }); builder.setNegativeButton( R.string.sure, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // 退出 AppManager.getAppManager().AppExit(cont); } }); builder.show(); }
@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("确定删除吗"); builder.setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { addresses.remove(arg2); adapter.setData(addresses); } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); builder.create(); builder.show(); return false; }
private void confirmDeleteDialog(OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View contents = View.inflate(this, R.layout.delete_thread_dialog_view, null); TextView msg = (TextView) contents.findViewById(R.id.message); msg.setText(R.string.confirm_delete_selected_messages); final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked); if (mSelectedLockedUris.size() == 0) { checkbox.setVisibility(View.GONE); } else { checkbox.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mIsDeleteLockChecked = checkbox.isChecked(); } }); } builder.setTitle(R.string.confirm_dialog_title); builder.setIconAttribute(android.R.attr.alertDialogIcon); builder.setCancelable(true); builder.setPositiveButton(R.string.yes, listener); builder.setNegativeButton(R.string.no, null); builder.setView(contents); builder.show(); }
@SuppressLint("InflateParams") private void quickEdit( final String previousValue, final OnValueEdited callback, boolean password) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.quickedit, null); final EditText editor = (EditText) view.findViewById(R.id.editor); OnClickListener mClickListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String value = editor.getText().toString(); if (!previousValue.equals(value) && value.trim().length() > 0) { callback.onValueEdited(value); } } }; if (password) { editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); editor.setHint(R.string.password); builder.setPositiveButton(R.string.accept, mClickListener); } else { builder.setPositiveButton(R.string.edit, mClickListener); } editor.requestFocus(); editor.setText(previousValue); builder.setView(view); builder.setNegativeButton(R.string.cancel, null); builder.create().show(); }
private AlertDialog showDownloadDialog() { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); downloadDialog.setTitle(title); downloadDialog.setMessage(message); downloadDialog.setPositiveButton( buttonYes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String packageName = targetApplications.get(0); Uri uri = Uri.parse("market://details?id=" + packageName); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { activity.startActivity(intent); } catch (ActivityNotFoundException anfe) { // Hmm, market is not installed Log.w(TAG, "Google Play is not installed; cannot install " + packageName); } } }); downloadDialog.setNegativeButton( buttonNo, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) {} }); return downloadDialog.show(); }
/** * @brief rateUS method * @param v * @detail This method is called when the rateUs button is clicked this calls another method * launchmarket which handles the call and contains the app's market link */ public void rateUS(View v) { final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(vibr); final AlertDialog.Builder alertbox = new AlertDialog.Builder(CaptureActivity.this); alertbox.setMessage(R.string.rate_us_text); // Message to be displayed alertbox.setPositiveButton( R.string.yes_btn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { launchMarket(); } }); alertbox.setNegativeButton( R.string.no_btn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {} }); // show the alert box will be swapped by other code later alertbox.show(); }
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); builder.setNegativeButton(null, null); builder.setPositiveButton(null, null); builder.setTitle(null); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get latitude and longitude double lat = getArguments().getDouble(BUNDLE_KEY_LAT); double lng = getArguments().getDouble(BUNDLE_KEY_LNG); loc = new LatLng(lat, lng); // Create the builder AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Set the title builder.setTitle("Pin a New Tak"); // Set the main content view LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.fragment_createtak, null); builder.setView(v); // Set positive and negative buttons builder.setPositiveButton("Pin", this); builder.setNegativeButton("Cancel", this); // Get widgets on the dialog fragment etTakName = (EditText) v.findViewById(R.id.addtak_et_takname); etTakDesc = (EditText) v.findViewById(R.id.addtak_et_description); etLat = (EditText) v.findViewById(R.id.addtak_et_lat); etLng = (EditText) v.findViewById(R.id.addtak_et_lng); // Add location passed in to the edit texts etLat.setText("" + loc.latitude); etLng.setText("" + loc.longitude); return builder.create(); }
/** Asks user to enable GPS */ private void showGPSDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder .setMessage(getStringResource(R.string.enable_gps)) .setCancelable(false) .setPositiveButton( getStringResource(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); } }); alertDialogBuilder.setNegativeButton( getStringResource(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
/** * Confirms if the user wants to really delete the photo * * @param photoId * @param activity */ public void confirmDelete(final int photoId, final DetailActivity activity) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder .setMessage(getStringResource(R.string.confirm_delete)) .setCancelable(false) .setPositiveButton( getStringResource(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { deletePhoto(photoId); if (activity != null) { Intent resultIntent = new Intent(); resultIntent.putExtra("id", photoId); resultIntent.putExtra("position", activity.position); activity.setResult(RESULT_DELETE, resultIntent); activity.finish(); } } }); alertDialogBuilder.setNegativeButton( getStringResource(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
@Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int position, long id) { ViewHolder holder = (ViewHolder) view.getTag(); Txt01 = (String) holder.text01.getText(); Txt02 = (String) holder.text02.getText(); Txt03 = (String) holder.text03.getText(); final AlertDialog.Builder dial = new AlertDialog.Builder(this); dial.setTitle("Suppression"); dial.setIcon(R.drawable.ad_question); dial.setMessage("Confirmez vous la suppression du produit suivant: " + "" + Txt03); dial.setPositiveButton( "Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { gotoSupprProduit(Txt01, Txt03); } }); dial.setNegativeButton("Non", null); dial.show(); return false; }
public void showEditDialog( Context context, String hintText, String OKText, final DialogCallBack callBack) { final EditText et_search; AlertDialog.Builder dialog = new AlertDialog.Builder(context); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_view, null); dialog.setView(layout); et_search = (EditText) layout.findViewById(R.id.searchC); et_search.setHint(hintText); dialog.setPositiveButton( OKText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String s = et_search.getText().toString().trim(); callBack.exectEditEvent(s); } }); dialog.setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {} }); dialog.show(); }
private void ShowSaveConfirmDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.layout.select_dialog_item); builder.setNegativeButton( getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(P005AlertDialogProf.this, "Negative", Toast.LENGTH_SHORT).show(); textViewP005.setText(R.string.failed); } }); builder.setPositiveButton( getResources().getString(R.string.save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(P005AlertDialogProf.this, "Positive", Toast.LENGTH_SHORT).show(); textViewP005.setText(R.string.successful); } }); builder.setTitle("Are you sure?"); builder.setIcon(R.drawable.fadein); builder.create(); builder.show(); }
public static void doodleAddText(final Context context, final DoodleView doodleView) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("请输入文字"); final EditText editText = new EditText(context); builder.setView(editText); builder.setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = editText.getText().toString(); doodleView.setMode(DoodleView.Mode.TEXT_MODE); doodleView.addTextAction(text); Toast.makeText( context, context.getString(R.string.set_doodle_font_size_and_position), Toast.LENGTH_LONG) .show(); } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {} }); builder.show(); }
private void showConfirmDialog(final int monthType) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(this); int[] month = {1, 3, 6, 12}; int[] money = {11000, 31000, 61000, 110000}; builder.setMessage("开通" + month[monthType] + "个月会员,需花费" + money[monthType] + "金币"); builder.setPositiveButton( "开通", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub buyVIP(monthType); } }); builder.setNegativeButton( "取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); AlertDialog confDialog = builder.create(); confDialog.show(); }
private void handleGevondenAlert(final Clue selectedClue, final Clue currentTargetClue) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle("Gevonden: " + currentTargetClue.getName()); alert.setMessage("Woord"); // Set an EditText view to get user input final EditText input = new EditText(context); alert.setView(input); alert.setPositiveButton( "Versturen", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String word = input.getText().toString(); new GevondenTask(context, huntedService, word, selectedClue.getName()).execute(null); // map.createMapOverlay(); // map.moveMapToClue(selectedClue); // Do something with value! } }); alert.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
/** * This displays a pop up that asks the user whether they want to add the appointment to their * native android calendar. If yes, another method is invoked to do this. * * @param details all of the details about the appointment * @param id the id of the appointment in the database */ private void addToCalendarQuestion(final HashMap<String, String> details, final int id) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Add To Calendar"); alert.setMessage("Do you want to add this appointment to your phones calendar?"); alert.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { addToCalendar(details, id); } }); alert.setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); getIntent(); } }); alert.show(); }
public void submit(View view) { AlertDialog.Builder saveDialog = new AlertDialog.Builder(this); saveDialog.setTitle("Confirm Receipt"); saveDialog.setMessage("Confirm Receipt of Delivery?"); saveDialog.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { drawing.setDrawingCacheEnabled(true); Bitmap sign = drawing.getDrawingCache(); // CONVERT TO BYTE ARRAY ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); sign.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); // CONVERT TO BASE 64 String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); confirmReceipt(encoded); } }); saveDialog.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); saveDialog.show(); }
public void doThis(final Button button) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("What do you want to do?"); LinearLayout llAlert = new LinearLayout(this); llAlert.setOrientation(1); alert.setView(llAlert); alert.setPositiveButton( "Edit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { edit(button); } }); alert.setNegativeButton( "Delete", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { delete(button); } }); alert.show(); }
public AlertDialog makeErrorDialog( final Activity context, String error, final String[] permissions, final boolean sso) { AlertDialog.Builder builder = dialogFactory.getAlertDialogBuilder(context); builder.setTitle("Oops!"); builder.setMessage("Oops!\nSomething went wrong...\n[" + error + "]"); builder.setCancelable(false); builder.setPositiveButton( "Try again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); authenticate(context, permissions, sso); } }); builder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); finish(context); } }); AlertDialog dialog = builder.create(); return dialog; }
protected void initializeAlertDialog() { alertDialog = new AlertDialog.Builder(act); alertDialog.setCancelable(false); // Setting Dialog Title alertDialog.setTitle(act.getString(R.string.conex)); // Setting Dialog Message alertDialog.setMessage(act.getString(R.string.conex_question)); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.delete); // Setting Positive "Yes" Button alertDialog.setPositiveButton( act.getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { act.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); dialog.cancel(); } }); // Setting Negative "NO" Button alertDialog.setNegativeButton( act.getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); act.finish(); } }); }
private void showProfileDialog() { AlertDialog.Builder alert = new AlertDialog.Builder(BaseActivity.this); alert.setItems( new String[] { getResources().getString(R.string.view_profile), getResources().getString(R.string.log_out) }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: showUserProfile(); break; case 1: logOut(); break; } } }); alert.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog ad = alert.create(); ad.show(); }
private void showLocationServiceDisabledAlertToUser() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder // GPS is disabled in your device. Would you like to enable it? .setMessage(R.string.location_services_on_device_deactivated) .setCancelable(false) // Goto Settings Page To Enable GPS .setPositiveButton( R.string.activate_location_services_on_device, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(callGPSSettingIntent); } }); alertDialogBuilder.setNegativeButton( "Fortryd", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.show(); }
/** * Function to show settings alert dialog On pressing Settings button will lauch Settings Options */ public void showSettingsAlert() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); // Setting Dialog Title alertDialog.setTitle("GPS is settings"); // Setting Dialog Message alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?"); // On pressing Settings button alertDialog.setPositiveButton( "Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); mContext.startActivity(intent); } }); // on pressing cancel button alertDialog.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
/** * Onclick para el boton de actualizar los aeropuertos. * * @param v */ public void onClickActualizarAeropuertos(View v) { AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertbox.setMessage( "Esta operación puede tardar varios minutos y se aconseja tener Wifi (Podrás seguir utilizando la aplicación)"); alertbox.setTitle("Actualizar Aeropuertos"); alertbox.setPositiveButton( "Si", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { if (tieneRed()) { actualizarAeropuertos(ORIGENES); } else { Toast toast = Toast.makeText( context, "Necesitas internet para actualizar.", Toast.LENGTH_SHORT); toast.show(); } } }); alertbox.setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) {} }); alertbox.show(); }