List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void showVersionInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")"); builder.setMessage(getVersionInfo(false)); builder.setIcon(R.drawable.ic_launcher); builder.setPositiveButton(getString(android.R.string.copy), new DialogInterface.OnClickListener() { @Override//from w ww. j a va2 s . c om public void onClick(DialogInterface dialog, int which) { DeprecatedUtils.setClipboard(getBaseContext(), getVersionInfo(true)); } }); builder.create().show(); }
From source file:net.granoeste.scaffold.app.ScaffoldAlertDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { int iconId = getArguments().getInt(ICON_ID, 0); String title = getArguments().getString(TITLE); String message = getArguments().getString(MESSAGE); boolean hasPositive = getArguments().getBoolean(HAS_POSITIVE, false); boolean hasNeutral = getArguments().getBoolean(HAS_NEUTRAL, false); boolean hasNegative = getArguments().getBoolean(HAS_NEGATIVE, false); String positiveText = getArguments().getString(POSITIVE_TEXT); String neutralText = getArguments().getString(NEUTRAL_TEXT); String negativeText = getArguments().getString(NEGATIVE_TEXT); boolean cancelable = getArguments().getBoolean(CANCELABLE, true); boolean canceledOnTouchOutside = getArguments().getBoolean(CANCELED_ON_TOUCH_OUTSIDE, false); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (iconId > 0) { builder.setIcon(iconId);/* w w w.j av a2 s . c o m*/ } if (StringUtils.isNoneEmpty(title)) { builder.setTitle(title); } if (StringUtils.isNoneEmpty(message)) { builder.setMessage(message); } if (hasPositive) { if (StringUtils.isEmpty(positiveText)) { positiveText = getResources().getString(R.string.yes); } builder.setPositiveButton(positiveText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNeutral) { if (StringUtils.isEmpty(neutralText)) { neutralText = getResources().getString(R.string.no); } builder.setNeutralButton(neutralText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNegative) { if (StringUtils.isEmpty(negativeText)) { negativeText = getResources().getString(hasNeutral ? R.string.cancel : R.string.no); } builder.setNegativeButton(negativeText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } builder.setCancelable(cancelable); if (cancelable) { builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogCancel(dialog, getTag()); } } } }); } // View customView = getCustomView(); if (mCustomView != null) { builder.setView(mCustomView); } Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(canceledOnTouchOutside); return dialog; }
From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java
private void handlePromptCancelSubscription() { AlertDialog.Builder builder = new AlertDialog.Builder(subscriptionActivity); builder.setTitle(R.string.cancel_subscription); builder.setMessage(R.string.are_you_sure_you_want_to_cancel_your_flock_subscription); builder.setNegativeButton(R.string.no, null); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override//from ww w .j av a 2 s . co m public void onClick(DialogInterface dialog, int id) { handleCancelSubscription(); } }); alertDialog = builder.show(); }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android confirm dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The index of the button pressed will be returned to the JavaScript callback identified by callbackId. * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. */// www. j av a 2s . c o m public synchronized void confirm(final String message, final String title, final JSONArray buttonLabels, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java
private Dialog assignFailDialog(Context context, String str) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);//from ww w .j a va 2 s.co m builder.setTitle(R.string.assign_confirm_title); builder.setMessage(str); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { setHints(); } }); return builder.create(); }
From source file:git.lawpavilionprime.auth._Login.java
public void connectIfInternetIsAvailable() { if (config.isConnectingToInternet()) { txtProgressMessage.setText("Please wait..."); mProgressBar.setVisibility(View.VISIBLE); AsyncManager.runBackgroundTask(new _AsyncLogin()); } else {/*from w w w .ja v a2s . c o m*/ 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) { mProgressBar.setVisibility(View.GONE); } }).setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { connectIfInternetIsAvailable(); } }); AlertDialog dialog = builder.create(); dialog.show(); } }
From source file:git.lawpavilionprime.auth._Login.java
@Override public void onBackPressed() { if (isAsyncTaskRunning) { AlertDialog.Builder builder = new AlertDialog.Builder(_Login.this); builder.setTitle("Info"); builder.setMessage( "You are about to exit the application\n\nYour Login is almost complete, Do you want to continue?") .setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override/*from w ww. ja v a2s. c o m*/ public void onClick(DialogInterface dialog, int which) { Log.d("BACK", "BACK PRESSED"); mProgressBar.setVisibility(View.GONE); AsyncManager.cancelAllTasks(); _Login.this.finish(); } }).setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); backPressedDialog = builder.create(); backPressedDialog.show(); } else { super.onBackPressed(); } }
From source file:fi.mikuz.boarder.gui.internet.InternetMenu.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.internet_menu); setTitle("Internet Menu"); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); mWaitDialog = new TimeoutProgressDialog(this, "Waiting for response", TAG, true); mInternetDownload = (Button) findViewById(R.id.internet_download); mInternetRegisterSettings = (Button) findViewById(R.id.internet_register_settings); mInternetLoginLogout = (Button) findViewById(R.id.internet_login_logout); mInternetUploads = (Button) findViewById(R.id.internet_uploads); mInternetFavorites = (Button) findViewById(R.id.internet_favorites); mAccountMessage = (TextView) findViewById(R.id.account_message_text); mDbHelper = new LoginDbAdapter(this); mDbHelper.open();//from w w w . j av a 2 s. com mGlobalVariableDbHelper = new GlobalVariablesDbAdapter(this); mGlobalVariableDbHelper.open(); int dbTosVersion = 0; try { Cursor variableCursor = mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY); startManagingCursor(variableCursor); dbTosVersion = variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); } catch (SQLException e) { mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0); Log.d(TAG, "Couldn't get tosVersion", e); } catch (CursorIndexOutOfBoundsException e) { mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0); Log.d(TAG, "Couldn't get tosVersion", e); } if (dbTosVersion < mTosVersion) { AlertDialog.Builder builder = new AlertDialog.Builder(InternetMenu.this); builder.setTitle("Terms of service"); builder.setMessage("Excited to get your hands on those sweet boards? - Good.\n\n" + "There are some terms you must agree to and follow to get things rolling smoothly;\n\n" + "You may only communicate in English in the Boarder Internet service.\n\n" + "An uploaded board may contain any languages. However, if the board is not 'in English' that must be visibly stated in the description.\n\n" + "You agree to always follow applicable laws when using Boarder.\n\n" + "Pornographic and other adult only material is not allowed.\n\n" + "You must be at least 13 years old to register to the Boarder Internet service.\n\n" + "You may never transmit anything or communicate a way that can be deemed offensive.\n\n" + "Don't make cheap copies of another users boards.\n\n" + "We can use material(s) publicly shared by you as promotional material.\n\n" + "We will suspend your Boarder releated accounts and/or remove your material from the Boarder service if you behave badly."); builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mGlobalVariableDbHelper.updateIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, mTosVersion); } }); builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { InternetMenu.this.finish(); } }); builder.setCancelable(false); builder.show(); } if (mLoginInfo == null) { try { String userId; String sessionToken; Cursor loginCursor = mDbHelper.fetchLogin(USER_ID_KEY); startManagingCursor(loginCursor); userId = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); loginCursor = mDbHelper.fetchLogin(SESSION_TOKEN_KEY); startManagingCursor(loginCursor); sessionToken = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); mLoginInfo = new HashMap<String, String>(); mLoginInfo.put(USER_ID_KEY, userId); mLoginInfo.put(SESSION_TOKEN_KEY, sessionToken); sendDonationInfo(); mSessionValidityChecked = false; checkSessionValidity(); } catch (CursorIndexOutOfBoundsException e) { Log.d(TAG, "Couldn't get database session info", e); mSessionValidityChecked = true; } } getVersionInfo(); // Keep under login stuff mInternetDownload.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, DownloadBoardList.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivity(i); } }); mInternetRegisterSettings.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mInternetRegisterSettings.getText().toString().equals(SETTINGS_TEXT)) { Intent i = new Intent(InternetMenu.this, Settings.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } else { Intent i = new Intent(InternetMenu.this, Register.class); startActivity(i); } } }); mInternetLoginLogout.setOnClickListener(new OnClickListener() { public void onClick(View v) { startLogin(); } }); mInternetUploads.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, Uploads.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } }); mInternetFavorites.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(InternetMenu.this, Favorites.class); i.putExtra(LOGIN_KEY, mLoginInfo); startActivityForResult(i, LOGIN_RETURN); } }); }
From source file:com.irccloud.android.fragment.EditConnectionFragment.java
private void init(View v) { channelsWrapper = (LinearLayout) v.findViewById(R.id.channels_wrapper); presets = (Spinner) v.findViewById(R.id.presets); hostname = (EditText) v.findViewById(R.id.hostname); port = (EditText) v.findViewById(R.id.port); ssl = (SwitchCompat) v.findViewById(R.id.ssl); nickname = (EditText) v.findViewById(R.id.nickname); realname = (EditText) v.findViewById(R.id.realname); channels = (EditText) v.findViewById(R.id.channels); nickserv_pass = (EditText) v.findViewById(R.id.nickservpassword); join_commands = (EditText) v.findViewById(R.id.commands); server_pass = (EditText) v.findViewById(R.id.serverpassword); network = (EditText) v.findViewById(R.id.network); presets.setOnItemSelectedListener(new OnItemSelectedListener() { @Override/*from w ww . j a v a 2 s .c o m*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { if (server != null) { hostname.setText(server.hostname); port.setText(String.valueOf(server.port)); ssl.setChecked(server.ssl == 1); } else { if (default_hostname != null) hostname.setText(default_hostname); else hostname.setText(""); port.setText(String.valueOf(default_port)); ssl.setChecked(default_port == 6697); } } else { PresetServersAdapter.PresetServer s = (PresetServersAdapter.PresetServer) adapter .getItem(position); hostname.setText(s.host); port.setText(String.valueOf(s.port)); ssl.setChecked(s.port == 6697); } } @Override public void onNothingSelected(AdapterView<?> parent) { if (server != null) { hostname.setText(server.hostname); port.setText(String.valueOf(server.port)); ssl.setChecked(server.ssl == 1); } else { if (default_hostname != null) hostname.setText(default_hostname); else hostname.setText(""); port.setText(String.valueOf(default_port)); ssl.setChecked(default_port == 6697); } } }); if (NetworkConnection.getInstance().getUserInfo() != null && !NetworkConnection.getInstance().getUserInfo().verified) { Button b = (Button) v.findViewById(R.id.resend); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NetworkConnection.getInstance().resend_verify_email(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Confirmation Sent"); builder.setMessage("You should shortly receive an email with a link to confirm your address."); builder.setNeutralButton("Close", null); builder.show(); } }); v.findViewById(R.id.unverified).setVisibility(View.VISIBLE); } }
From source file:com.google.zxing.client.android.result.ResultHandler.java
/** * Like {@link #rawLaunchIntent(Intent)} but will show a user dialog if nothing is available to handle. *///from w w w . java 2 s. c o m final void launchIntent(Intent intent) { try { rawLaunchIntent(intent); } catch (ActivityNotFoundException ignored) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.app_name); builder.setMessage(R.string.msg_intent_failed); builder.setPositiveButton(R.string.button_ok, null); builder.show(); } }