List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:com.binomed.showtime.android.util.activity.AbstractCineShowTimeActivity.java
@Override public final void openErrorDialog(int errorMsg) { closeDialog();//from w w w .ja v a 2 s. co m AlertDialog.Builder errorDialog = new AlertDialog.Builder(this); errorDialog.setTitle(R.string.errorMsg); errorDialog.setMessage(getResources().getString(errorMsg)); errorDialog.setCancelable(false); errorDialog.setNeutralButton(R.string.btnClose, null); errorDialog.show(); }
From source file:com.orangelabs.rcs.ri.extension.messaging.MessagingSessionView.java
private void initialiseMessagingSession(Intent intent) { MultimediaSessionService sessionApi = mCnxManager.getMultimediaSessionApi(); try {/* www . jav a 2s . c o m*/ MultimediaSessionServiceConfiguration config = sessionApi.getConfiguration(); if (LogUtils.isActive) { Log.d(LOGTAG, "MessageMaxLength: ".concat(Integer.toString(config.getMessageMaxLength()))); } int mode = intent.getIntExtra(MessagingSessionView.EXTRA_MODE, -1); if (mode == MessagingSessionView.MODE_OUTGOING) { // Outgoing session // Check if the service is available if (!sessionApi.isServiceRegistered()) { Utils.showMessageAndExit(this, getString(R.string.label_service_not_available), mExitOnce); return; } // Get remote contact mContact = intent.getParcelableExtra(MessagingSessionView.EXTRA_CONTACT); // Initiate session startSession(); } else if (mode == MessagingSessionView.MODE_OPEN) { // Open an existing session // Incoming session mSessionId = intent.getStringExtra(MessagingSessionView.EXTRA_SESSION_ID); // Get the session mSession = sessionApi.getMessagingSession(mSessionId); if (mSession == null) { // Session not found or expired Utils.showMessageAndExit(this, getString(R.string.label_session_has_expired), mExitOnce); return; } // Get remote contact mContact = mSession.getRemoteContact(); } else { // Incoming session from its Intent mSessionId = intent.getStringExtra(MultimediaMessagingSessionIntent.EXTRA_SESSION_ID); // Get the session mSession = sessionApi.getMessagingSession(mSessionId); if (mSession == null) { // Session not found or expired Utils.showMessageAndExit(this, getString(R.string.label_session_has_expired), mExitOnce); return; } // Get remote contact mContact = mSession.getRemoteContact(); String from = RcsDisplayName.getInstance(this).getDisplayName(mContact); // Manual accept AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.title_messaging_session); builder.setMessage(getString(R.string.label_mm_from_id, from, mServiceId)); builder.setCancelable(false); builder.setIcon(R.drawable.ri_notif_mm_session_icon); builder.setPositiveButton(getString(R.string.label_accept), acceptBtnListener); builder.setNegativeButton(getString(R.string.label_decline), declineBtnListener); builder.show(); } // Display session info TextView featureTagEdit = (TextView) findViewById(R.id.feature_tag); featureTagEdit.setText(mServiceId); String from = RcsDisplayName.getInstance(this).getDisplayName(mContact); TextView contactEdit = (TextView) findViewById(R.id.contact); contactEdit.setText(from); Button sendBtn = (Button) findViewById(R.id.send_btn); if (mSession != null) { sendBtn.setEnabled(true); } else { sendBtn.setEnabled(false); } } catch (RcsServiceException e) { Utils.showMessageAndExit(this, getString(R.string.label_api_failed), mExitOnce, e); } }
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. *///from w ww . j av a2 s .c om 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:com.flowzr.activity.Report2DChartActivity.java
/** * Display a message when preferences not set to alert the use of default values. * @param isCurrency Inform if currency is not set on report preferences. * @param isPeriod Inform if period is not set on report preferences. */// w w w . java2 s . com private void alertPreferencesNotSet(boolean isCurrency, boolean isPeriod) { // display message: preferences not set String message = ""; if (isCurrency) { if (isPeriod) { // neither currency neither period is set message = getResources().getString(R.string.report_preferences_not_set); } else { // only currency not set message = getResources().getString(R.string.currency_not_set); } } else { if (isPeriod) { // only period not set message = getResources().getString(R.string.period_not_set); } } AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this.getActivity()); dlgAlert.setMessage(message); dlgAlert.setTitle(R.string.reports); dlgAlert.setPositiveButton(R.string.ok, null); dlgAlert.setCancelable(true); dlgAlert.create().show(); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * /*from w w w . j a va 2 s.c o m*/ * @return */ @Override protected Dialog createCPUDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createCPUListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(CPU_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("CPU usages"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status./* w ww. ja v a 2 s . c o m*/ * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk usage"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.patil.geobells.lite.MainActivity.java
public void checkLocationServicesEnabled() { LocationManager lm = null;/*from w ww .ja v a2s . com*/ boolean gps_enabled = true, network_enabled = true; if (lm == null) lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); try { gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception ex) { } try { network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch (Exception ex) { } if (!gps_enabled || !network_enabled) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle(R.string.dialog_title_enable_locationservices); dialog.setMessage(getString(R.string.dialog_message_enable_locationservices)); dialog.setCancelable(false); dialog.setPositiveButton(getString(R.string.dialog_button_open_location_settings), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface paramDialogInterface, int paramInt) { paramDialogInterface.dismiss(); Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(myIntent); } }); dialog.setNegativeButton(getString(R.string.dialog_button_nothanks), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface paramDialogInterface, int paramInt) { finish(); } }); dialog.create().show(); } }
From source file:de.evilbrain.sendtosftp.Main.java
public String serverListGetActive() { // Get selected Radio Button int selectedId = serverList.getCheckedRadioButtonId(); // Get text from radio-button RadioButton actualradioButton = (RadioButton) findViewById(selectedId); if (actualradioButton == null) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); dlgAlert.setTitle("Select an Server"); dlgAlert.setMessage("Please select an server from the list"); dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { }/*from w w w .j ava2 s . c om*/ }); dlgAlert.setCancelable(true); dlgAlert.create().show(); return null; } return actualradioButton.getText().toString(); }
From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java
public void showInfo(View view) { String title = "Sensor Frequency:"; // Includes the updates as well so users know what changed. String message = "\n\n- Settings to control the frequency of Sensors." + "\nClick on the options to switch off or change the frequency." + "\n- Various levels of frequency can be selected" + "\n - HIGH, MEDIUM, LOW or OFF" + "\n Please note if the Nervousnet Service is Paused, this control is disabled."; AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(title).setMessage(message) .setPositiveButton("OK", new Dialog.OnClickListener() { @Override//from ww w . j a v a 2 s . co m public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setCancelable(false); AlertDialog alert = builder.create(); alert.show(); alert.getWindow().getAttributes(); TextView textView = (TextView) alert.findViewById(android.R.id.message); textView.setTextSize(12); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status./*from w w w. j a va2s. c om*/ * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskBusyDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskBusyListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_BUSY_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk busy"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }