//This is deprecated in API level 8 //protected override Dialog OnCreateDialog(int id) //This is deprecated in API level 13 protected override Dialog OnCreateDialog(int id, Bundle args) { switch(id) { case AlertDialog: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.bomb_dialog_title); builder.SetPositiveButton(Resource.String.dialog_signal, (s, e) => { /*Do something here!*/ }); builder.SetNegativeButton(Resource.String.dialog_main_screen, (s, e) => { }); return builder.Create(); } case ListDialog: { var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(Resource.String.list_dialog_title); builder.SetSingleChoiceItems(Resource.Array.list_dialog_items, 0, ListClicked); builder.SetPositiveButton(Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.dialog_cancel, CancelClicked); return builder.Create(); } case MultiChoiceDialog: { var builder = new AlertDialog.Builder(this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIcon(Resource.Drawable.Icon); builder.SetTitle(Resource.String.multi_choice_dialog_title); builder.SetMultiChoiceItems(Resource.Array.multilist_dialog_items, new[] { false, true, false, true }, MultiListClicked); builder.SetPositiveButton(Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton(Resource.String.multi_dialog_cancel, CancelClicked); return builder.Create(); } case CustomViewDialog: { var customView = LayoutInflater.Inflate (Resource.Layout.CustomDialog, null); var builder = new AlertDialog.Builder (this); builder.SetView(customView); builder.SetPositiveButton (Resource.String.dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.dialog_cancel, CancelClicked); return builder.Create (); } } return base.OnCreateDialog(id, args); }
private void Alert(string message, string title, string okButton) { Application.SynchronizationContext.Post(ignored => { var builder = new AlertDialog.Builder(CurrentActivity); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(title); builder.SetMessage(message); builder.SetPositiveButton(okButton, delegate { }); builder.Create().Show(); }, null); }
private void ClearSQLiteData() { try { // First ask and confirm for the process var alertdialog = new AlertDialog.Builder(this); alertdialog.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); alertdialog.SetTitle(Resource.String.OfflineData); // If yes delete the data alertdialog.SetPositiveButton(Resource.String.Yes, delegate (object o, DialogClickEventArgs d) { if (DataAccessLayer.SQLiteUtilities.ClearData() == true) { var successdialog = new AlertDialog.Builder (this); successdialog.SetTitle (Resource.String.OfflineData); successdialog.SetMessage(GetString(Resource.String.ClearedSuccessfully)); successdialog.SetPositiveButton("OK",delegate (object os, DialogClickEventArgs ds) {}); successdialog.Show(); } ; } ); alertdialog.SetNegativeButton(Resource.String.No, delegate (object o, DialogClickEventArgs d) {}); alertdialog.SetMessage(GetString(Resource.String.ClearMessage)); alertdialog.Show(); } catch (Exception ex) { DataAccessLayer.ExceptionWriter.WriteLogFile(ex); } }
private void UploadData() { // Check if there is any offline data that has to be uploaded var alertdialog = new AlertDialog.Builder(this); alertdialog.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); alertdialog.SetTitle(Resource.String.OfflineData); alertdialog.SetPositiveButton(Resource.String.Yes, OfflineDataYesClicked); alertdialog.SetNegativeButton(Resource.String.No, OfflineDataNoClicked); if (offlineTasks == 1) alertdialog.SetMessage(String.Format(GetString(Resource.String.AskUpload), offlineTasks)); else alertdialog.SetMessage(String.Format(GetString(Resource.String.AskUploads), offlineTasks)); alertdialog.Show(); }
protected override Dialog OnCreateDialog(int id) { switch (id) { case DIALOG_YES_NO_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeTraditional); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons2ultra_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_LIST: { var builder = new AlertDialog.Builder (this); builder.SetTitle (Resource.String.select_dialog); builder.SetItems (Resource.Array.select_dialog_items, ListClicked); return builder.Create (); } case DIALOG_PROGRESS: { progress_dialog = new ProgressDialog (this); progress_dialog.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); progress_dialog.SetTitle (Resource.String.select_dialog); progress_dialog.SetProgressStyle (ProgressDialogStyle.Horizontal); progress_dialog.Max = MAX_PROGRESS; progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonPositive, GetText (Resource.String.alert_dialog_ok), OkClicked); progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonNegative, GetText (Resource.String.alert_dialog_cancel), CancelClicked); return progress_dialog; } case DIALOG_SINGLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_single_choice); builder.SetSingleChoiceItems (Resource.Array.select_dialog_items2, 0, ListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice); builder.SetMultiChoiceItems (Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE_CURSOR: { var projection = new string[] { BaseColumns.Id, Contacts.PeopleColumns.DisplayName, Contacts.PeopleColumns.SendToVoicemail }; var cursor = ManagedQuery (ContactsContract.Contacts.ContentUri, projection, null, null, null); var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice_cursor); builder.SetMultiChoiceItems (cursor, Contacts.PeopleColumns.SendToVoicemail, Contacts.PeopleColumns.DisplayName, MultiListClicked); return builder.Create (); } case DIALOG_TEXT_ENTRY: { // This example shows how to add a custom layout to an AlertDialog var factory = LayoutInflater.From (this); var text_entry_view = factory.Inflate (Resource.Layout.alert_dialog_text_entry, null); var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_text_entry); builder.SetView (text_entry_view); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } } return null; }
public void UpdateNetworkStatus() { try { ActivityController++; _state = DataAccessLayer.NetworkState.Unknown; // Retrieve the connectivity manager service var connectivityManager = (ConnectivityManager) Application.Context.GetSystemService ( Context.ConnectivityService); // Check if the network is connected or connecting. // This means that it will be available, // or become available in a few seconds. var activeNetworkInfo = connectivityManager.ActiveNetworkInfo; Android.Content.Res.Resources res = _activity.Resources; NotificationManager notificationManager = (NotificationManager) _activity.GetSystemService ( Android.Content.Context.NotificationService); Android.Net.Uri uri = null; if (activeNetworkInfo == null) { // Send the two notification: // 1. There is no connection. // 2. The user is offline if (ActivityController > 1) uri = Android.Media.RingtoneManager.GetDefaultUri ( Android.Media.RingtoneType.Notification); Notification.Builder builder = new Notification.Builder (_activity) .SetSmallIcon (Resource.Drawable.ic_network_disconnected) .SetAutoCancel (false) .SetSound (uri) //.SetVibrate (new long[] { 1000, 1000, 1000, 1000, 1000 }) .SetLights (54, 3000, 5) .SetContentText ( _activity.Resources.GetString(Resource.String.NetworkDisconnected)) .SetContentTitle (_activity.Resources.GetString(Resource.String.AppName) + " - " + _activity.Resources.GetString(Resource.String.Disconnected)) .SetContentIntent (GetDialogPendingIntent ()) .SetTicker (_activity.Resources.GetString(Resource.String.Disconnected)); Notification notification = builder.Build(); notificationManager.Notify (1, notification); builder = new Notification.Builder (_activity) .SetSmallIcon (UI.Resource.Drawable.ic_action_offline) .SetAutoCancel (false) .SetSound (Android.Media.RingtoneManager.GetDefaultUri ( Android.Media.RingtoneType.Notification)) .SetLights (54,3000,5) .SetContentText ( _activity.Resources.GetString(Resource.String.UserOffline)) .SetContentTitle (_activity.Resources.GetString(Resource.String.AppName) + " - " + "Offline") .SetTicker (_activity.Resources.GetString(Resource.String.UserOffline)); notification = builder.Build(); notificationManager = (NotificationManager) _activity.GetSystemService ( Android.Content.Context.NotificationService); notificationManager.Notify (2, notification); /*AlertDialog a = new AlertDialog.Builder (this) .SetTitle ("NETWORK") .SetMessage ("No Network") .SetPositiveButton (Android.Resource.String.Ok, delegate (object o, DialogClickEventArgs e) {}) .Create(); a.Show ();*/ _state = DataAccessLayer.NetworkState.Disconnected; return; } if (activeNetworkInfo.IsConnectedOrConnecting) { if (ActivityController > 1) uri = Android.Media.RingtoneManager.GetDefaultUri ( Android.Media.RingtoneType.Notification); Notification.Builder builder = new Notification.Builder (_activity) .SetSmallIcon (UI.Resource.Drawable.ic_network_connected) .SetAutoCancel (false) .SetSound (uri) //.SetVibrate (new long[] { 10, 0 }) .SetLights (54,3000,5) .SetContentTitle (_activity.Resources.GetString(Resource.String.AppName) + " - " + _activity.Resources.GetString(Resource.String.Connected)) .SetContentIntent (GetDialogPendingIntent ()) .SetTicker (_activity.Resources.GetString(Resource.String.Connected)); //.SetContentIntent (GetDialogPendingIntent ("Connected.")); // According to the status of the user, adjust the text of the notification if (MainActivity.User.NetworkStatus == DataAccessLayer.NetworkState.Disconnected) builder.SetContentText( _activity.Resources.GetString(Resource.String.NetworkConnected)); else builder.SetContentText( _activity.Resources.GetString(Resource.String.NetworkConnected)); Notification notification = builder.Build(); notificationManager.Notify (1, notification); // Now that we know it's connected, determine if we're on WiFi or something else. _state = activeNetworkInfo.Type == ConnectivityType.Wifi ? DataAccessLayer.NetworkState.ConnectedWifi : DataAccessLayer.NetworkState.ConnectedData; // First check if there is any unsync data in the SQLite database offlineTasks = BusinessLayer.Task.HasNewOfflineTasks(); // If there is and the user is online then ask for synchronizing the data if (offlineTasks != 0 &&MainActivity.User.NetworkStatus != DataAccessLayer.NetworkState.Disconnected) { // Ask the user if he wants to upload the unsynchronized data var alertdialog = new AlertDialog.Builder(this._activity); alertdialog.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); alertdialog.SetTitle(Resource.String.OfflineData); alertdialog.SetPositiveButton(Resource.String.Yes, OfflineDataYesClicked); alertdialog.SetNegativeButton(Resource.String.No, OfflineDataNoClicked); // Set the right Message if (offlineTasks == 1) alertdialog.SetMessage(string.Format(_activity.GetString(Resource.String.AskUpload), offlineTasks)); else alertdialog.SetMessage(string.Format(_activity.GetString(Resource.String.AskUploads), offlineTasks)); alertdialog.Show(); } } else { if (ActivityController > 1) uri = Android.Media.RingtoneManager.GetDefaultUri ( Android.Media.RingtoneType.Notification); // Send the two notification: // 1. There is no connection. // 2. The user is offline Notification.Builder builder = new Notification.Builder (_activity) .SetSmallIcon (UI.Resource.Drawable.ic_network_disconnected) .SetAutoCancel (false) .SetSound (uri) //.SetVibrate (new long[] { 1000, 1000, 1000, 1000, 1000 }) .SetLights (54, 3000, 5) .SetContentText (_activity.Resources.GetString(Resource.String.NetworkDisconnected)) .SetContentTitle (_activity.Resources.GetString(Resource.String.AppName) + " - " + _activity.Resources.GetString(Resource.String.Disconnected)) .SetContentIntent (GetDialogPendingIntent ()) .SetTicker (_activity.Resources.GetString(Resource.String.Disconnected)); //.SetContentIntent (GetDialogPendingIntent ("Disconnected")); Notification notification = builder.Build(); notificationManager.Notify (1, notification); builder = new Notification.Builder (_activity) .SetSmallIcon (UI.Resource.Drawable.ic_action_offline) .SetAutoCancel (false) .SetSound (Android.Media.RingtoneManager.GetDefaultUri ( Android.Media.RingtoneType.Notification)) .SetLights (54,3000,5) .SetContentText ( _activity.Resources.GetString(Resource.String.UserOffline)) .SetContentTitle (_activity.Resources.GetString(Resource.String.AppName) + " - " + "Offline") .SetTicker (_activity.Resources.GetString(Resource.String.UserOffline)); notification = builder.Build(); notificationManager = (NotificationManager) _activity.GetSystemService ( Android.Content.Context.NotificationService); notificationManager.Notify (2, notification); /*AlertDialog a = new AlertDialog.Builder (this) .SetTitle ("NETWORK") .SetMessage ("Disconnected") .SetPositiveButton (Android.Resource.String.Ok, delegate (object o, DialogClickEventArgs e) {}) .Create();*/ _state = DataAccessLayer.NetworkState.Disconnected; } } catch(Exception ex) { DataAccessLayer.ExceptionWriter.WriteLogFile(ex); } }
protected override Dialog OnCreateDialog(int id) { if (id == 1) { var factory = LayoutInflater.From(this); var text_entry_view = factory.Inflate(Resource.Layout.Settings, null); var serverEdit = text_entry_view.FindViewById<EditText>(Resource.Id.server); serverEdit.Text = AppSettings.ApiUri.AbsoluteUri; var builder = new AlertDialog.Builder(this); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle("Settings"); builder.SetView(text_entry_view); builder.SetPositiveButton("Save", (sender, args) => { AppSettings.ApiUri = new Uri(serverEdit.Text); }); builder.SetNegativeButton("Cancel", (sender, args) => { }); return builder.Create(); } return base.OnCreateDialog(id); }
void SpinnerAnsprechpartner_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { if (_stateFragment._ansprechpartnern.Count > 0) { // If there are Ansprechpartner, just show as default AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectAnsprechpartner)); builder.SetItems(BusinessLayer.Ansprechpartner.ConvertToStringList(_stateFragment._ansprechpartnern, _activity.BaseContext.Resources.Configuration.Locale.Language.ToUpper()), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerAnsprechpartner.SetSelection(eDlg.Which); _stateFragment.SpinnerItemSelected(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } else { // If there is no Ansprechpartner just show a Dialog messaging "There is no Contact" AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectAnsprechpartner)); builder.SetItems(new string[]{_activity.GetString(Resource.String.NoAnsprechpartner)}, delegate(object senderDlg, DialogClickEventArgs eDlg) { }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } } }
void SpinnerLand_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectCountry)); builder.SetItems(BusinessLayer.Country.ConvertToStringList(BusinessLayer.UtilityClasses.countries, _activity.BaseContext.Resources.Configuration.Locale.Language.ToUpper()), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerLand.SetSelection(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } }
public void SpinnerStatus_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectStatus)); builder.SetItems(_stateFragment._taskStatus.ToArray(), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerStatus.SetSelection(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } }
void BtnDeletePosition_Click (object sender, EventArgs e) { // first check if an item in the listview is selected if (_tempPosition == null) return; // ask the user if he wants to delete this position var alertdialog = new AlertDialog.Builder(this._context); alertdialog.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); alertdialog.SetTitle("Apollo CRM"); alertdialog.SetPositiveButton(Resource.String.Yes, OfflineDataYesClicked); alertdialog.SetNegativeButton(Resource.String.No,OfflineDataNoClicked); alertdialog.SetMessage(Resource.String.WollenSieLoeschen); alertdialog.Show(); }