List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java
private void showConnectToAmritaAlert() { AlertDialog.Builder builder = new AlertDialog.Builder(baseContext); builder.setMessage("Connect to the Amrita WiFi if possible, for a reliable connection to the GPMS Server.") .setCancelable(true).setIcon(R.drawable.ic_action_info_small) .setPositiveButton("Ok. I'll connect.", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); finish();//from ww w . j a v a 2 s.co m } }).setNegativeButton("No. I won't.", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); initialiseGpms(); hideSoftKeyboard(); } }); AlertDialog alert = builder.create(); alert.requestWindowFeature(Window.FEATURE_NO_TITLE); if (!Identifier.isConnectedToAmrita(baseContext)) { alert.show(); } else { initialiseGpms(); } }
From source file:com.iss.android.wearable.datalayer.MainActivity.java
private void displayBatteryWarning(int warned) { // Display a cancelable warning that the HRM battery is running low. AlertDialog.Builder builder = new AlertDialog.Builder(this); String warning = ""; switch (warned) { case 1:/* w w w .j a va 2 s . c om*/ warning = "HRM Battery Level at 15%"; break; case 2: warning = "HRM Battery Level at 10%"; break; case 3: warning = "HRM Battery Level at 5%"; break; } Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(100); builder.setMessage(warning).setTitle(R.string.battery_warning_title).setCancelable(true) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.setCancelable(true); dialog.show(); }
From source file:com.chaturs.notepad.NoteEditor.java
private void showDialogForTitle() { View view = LayoutInflater.from(this).inflate(R.layout.dialog_title, null); final EditText edit = (EditText) view.findViewById(R.id.edit); Button okButton = (Button) view.findViewById(R.id.ok); Button cancelButton = (Button) view.findViewById(R.id.cancel); edit.setText(title);//w ww. j av a 2s .c o m AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Enter Title"); builder.setView(view); builder.setCancelable(false); okButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { title = edit.getText().toString(); if (title.trim().length() == 0) { edit.setError("Please Enter Some Text !"); return; } saveNote(); setTitle(title); dialog.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); }
From source file:com.abc.driver.TruckActivity.java
public void chooseTruckType(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);//from w w w .j a va 2 s . c o m // (GridView)findViewById(R.id.gridView1); SimpleAdapter adapter = new SimpleAdapter(this, mTruckTypeList, R.layout.truck_type_griditem, new String[] { "PIC", "TITLE", "TTYPE" }, new int[] { R.id.griditem_pic, R.id.griditem_title, R.id.griditem_type, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTTtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckType = ((TextView) view.findViewById(R.id.griditem_type)).getText().toString(); mUpdateTruckTask = new UpdateTruckTask(); mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), mTruckType, "" + app.getUser().getMyTruck().getLengthId(), "" + app.getUser().getMyTruck().getWeightId(), "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId()); dialog.dismiss(); } }); dialog.show(); }
From source file:com.android.settings.locationprivacy.LocationPrivacyAdvancedSettings.java
@Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("lp_settings_advanced_reset")) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.lp_settings_advanced_reset_warning) .setTitle(R.string.lp_settings_advanced_reset_warning_title) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override/*from ww w. j a v a 2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { lpManager.resetToFactoryDefaults(); lpManager = new LocationPrivacyManager(getActivity()); startFragment(getParentFragment(), LocationPrivacySettings.class.getName(), 0, new Bundle()); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do Nothing } }); AlertDialog dialog = builder.create(); dialog.show(); } else if (preference.getKey().equals("lp_settings_advanced_settings")) { if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()) != ConnectionResult.SUCCESS) { addNotification(GOOGLE_PLAY, R.string.lp_settings_google_play_service); } } return true; }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void showAddrPickerDialog() { // Set the current dialog currentDialog = ADDRESS_PICKER_DIALOG_ID; // Set the options in Address Picker Dialog final CharSequence[] items = { "Use Current Location", "Use Find's Location", "Enter Location Name / Landmark Address " }; // Build Address Picker Dialog AlertDialog.Builder addrPickerBuilder = new AlertDialog.Builder(this); addrPickerBuilder.setTitle("Step 2: Choose an address"); addrPickerBuilder.setItems(items, mAddrPickerOnClickListener); // Set Listeners addrPickerBuilder.setOnKeyListener(mBackKeyListener); // Finish the activity when the user presses cancel addrPickerBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK);//from w w w . j a v a2s . c o m finish(); } }); // Show Address Picker Dialog addrPickerDialog = addrPickerBuilder.create(); addrPickerDialog.show(); }
From source file:edu.missouri.bas.activities.AdminManageActivity.java
private Dialog buildDialog2(Context context, String str) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);/* w w w .jav a 2 s . com*/ builder.setTitle("Confirm"); builder.setMessage(str); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editor.putString(ASID, asID.getText().toString()); Log.d("here!!!", "id is " + asID.getText().toString()); //format check editor.putString(ASPWD, ""); editor.commit(); setHints(); setResult(8); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub setHints(); } }); return builder.create(); }
From source file:com.tarun.smartwomen.WebViewDemoActivity.java
@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" }) @Override/*from www .ja v a 2 s. c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.mainn); Intent intent = getIntent(); reg = intent.getBooleanExtra("reg", false); i = (ImageView) findViewById(R.id.hj); try { big = new GifAnimationDrawable(getResources().openRawResource(R.raw.anim2)); // big.setOneShot(true); android.util.Log.v("GifAnimationDrawable", "===>Four"); } catch (IOException ioe) { } i.setImageDrawable(big); big.setVisible(true, true); sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE); // historyStack = new LinkedList<Link>(); webview = (WebView) findViewById(R.id.webkit); WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); // webview.addJavascriptInterface(new WebViewDemoActivity(), "Android"); // webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // webview.getSettings().setPluginState(PluginState.ON); // webview.getSettings().setJavaScriptEnabled(true); } else { // IMPORTANT!! this method is no longer available since Android 4.3 // so the code doesn't compile anymore // webview.getSettings().setPluginsEnabled(true); } // Internet ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); connected = false; if ((null != connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) && connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED) || (null != connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI) && connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED)) { // we are connected to a network connected = true; } if (connected == false) { /* * Toast.makeText(Rss.this, * "Connect to internet and Restart Application", * Toast.LENGTH_SHORT).show(); */ webview.setVisibility(View.INVISIBLE); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(WebViewDemoActivity.this); // alertDialogBuilder.setTitle("Please connect to Internet"); alertDialogBuilder.setMessage( "In order to provide the freshest recipes and juicing information this app must be connected to the internet, please check your internet settings"); // set positive button: Yes message alertDialogBuilder.setNegativeButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // cancel the alert box and put a Toast to the user startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); } }); AlertDialog alertDialog = alertDialogBuilder.create(); // show alert alertDialog.show(); } // downloads // webview.setDownloadListener(new CustomDownloadListener()); webview.setWebViewClient(new CustomWebViewClient()); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { } @Override public void onReceivedTitle(WebView view, String title) { } @Override public void onReceivedIcon(WebView view, Bitmap icon) { } }); // http://stackoverflow.com/questions/2083909/android-webview-refusing-user-input webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); if (reg == true) { if (Locale.getDefault().getLanguage().equals("es")) { webview.loadUrl("http://om-msmartwoman.com/member/register"); // webview.loadUrl("http://live-juice-guru.gotpantheon.com/user/login"); } else { webview.loadUrl("http://om-msmartwoman.com/member/register"); } webview.requestFocus(); } else { uhdj = sp.getString("your_int_key", "0"); Log.e("Url is here ..............................", uhdj); // Welcome page loaded from assets directory if (Locale.getDefault().getLanguage().equals("es")) { webview.loadUrl(uhdj); // webview.loadUrl("http://live-juice-guru.gotpantheon.com/user/login"); } else { webview.loadUrl(uhdj); } webview.requestFocus(); } }
From source file:pl.bcichecki.rms.client.android.dialogs.EventDetailsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (event == null) { throw new IllegalStateException("Event has not been set!"); }// ww w .j a va 2s . c o m if (eventsRestClient == null) { throw new IllegalStateException("EventsRestClient has not been set!"); } if (eventsListAdapter == null) { throw new IllegalStateException("EventsListAdapter has not been set!"); } context = getActivity(); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(getString(R.string.dialog_event_details_title, event.getTitle())); dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_event_details, null)); final boolean isUserSignedUp = event.isUserSignedUp(UserProfileHolder.getUserProfile()); dialogBuilder.setNeutralButton( isUserSignedUp ? R.string.dialog_event_details_sign_out : R.string.dialog_event_details_sign_up, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { signUp(!isUserSignedUp); } }); dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Nothing to do... } }); AlertDialog dialog = dialogBuilder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { TextView descriptionTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_description_text); TextView devicesTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_devices_text); TextView endsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_ends_text); TextView participantsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_participants_text); TextView startsTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_starts_text); TextView titleTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_title_text); TextView eventTypeTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_event_details_type_text); titleTextView.setText(event.getTitle()); startsTextView .setText(AppUtils.getFormattedDateAsString(event.getStartDate(), Locale.getDefault())); endsTextView.setText(AppUtils.getFormattedDateAsString(event.getEndDate(), Locale.getDefault())); descriptionTextView.setText(event.getDescription()); if (event.getType().equals(EventType.MEETING)) { eventTypeTextView.setText(R.string.dialog_event_details_type_meeting); } if (event.getType().equals(EventType.INTERVIEW)) { eventTypeTextView.setText(R.string.dialog_event_details_type_interview); } if (event.getParticipants() != null && event.getParticipants().size() > 0) { StringBuilder participants = new StringBuilder(); int counter = 1; for (Iterator<User> participantIterator = event.getParticipants() .iterator(); participantIterator.hasNext();) { User participant = participantIterator.next(); participants.append(counter).append(". "); if (participant.getAddress() != null && participant.getAddress().getFirstName() != null && participant.getAddress().getLastName() != null) { participants.append(participant.getAddress().getFirstName()).append(" ") .append(participant.getAddress().getLastName()); } else { participants.append(participant.getUsername()); } if (participantIterator.hasNext()) { participants.append("\n"); counter++; } } participantsTextView.setText(participants); } else { participantsTextView.setText(R.string.dialog_event_details_no_participants); } if (event.getDevices() != null && event.getDevices().size() > 0) { StringBuilder devices = new StringBuilder(); int counter = 1; for (Iterator<Device> deviceIterator = event.getDevices().iterator(); deviceIterator .hasNext();) { Device device = deviceIterator.next(); devices.append(counter).append(". "); devices.append(device.getName()); if (deviceIterator.hasNext()) { devices.append("\n"); counter++; } } devicesTextView.setText(devices); } else { devicesTextView.setText(R.string.dialog_event_details_no_devices); } } }); return dialog; }
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 .j ava 2 s . co 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(); } }