i host asp.net core web api in iis and i consumed in xamarin forms and i got this error
java.net.unknownhostexception unable to resolve host no address associated with hostname
i already added the all permission in AndroidManifest.xml,
and api work fine in postman
Unable to resolve host No address associated with host name
Load Application(new App())
Hey developers
I am facing an issue for Load Application(new App())
`
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace Iot.Droid
{
[Activity(Label = "Iot", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); } public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) { Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); base.OnRequestPermissionsResult(requestCode, permissions, grantResults); } }
}`
It throws a missing assembly exception
Problems to use Plugin.BLE in Android 10
Hi guys. My name is Felipe i'm from Brazil.
Try to use Plugin.BLE but works only iOS and Android 8 or bottom.
The problem is on call await characterist.StartUpdateAsync(). On call this method in Android 10 the code skip the rest.
Someone help me?
This is my code:
if (device != null) { await adapter.StopScanningForDevicesAsync(); //await adapter.DisconnectDeviceAsync(device); await adapter.ConnectToDeviceAsync(device); var services = await device.GetServicesAsync(); ICharacteristic characteristicTemperature = null; ICharacteristic characteristicBattery = null; foreach (var service in services) { var caracteristicas = await service.GetCharacteristicsAsync(); foreach (var carac in caracteristicas) { var descritors = await carac.GetDescriptorsAsync(); //Bug android 9 ou > -- Problemas ao notificar o device //Checa se é Bateria ou Temperatura if (carac.Uuid == "2a19" || carac.Uuid == "2a1c" || carac.Name.ToLower().Equals("temperature measurement") || carac.Name.ToLower().Equals("battery level")) { if (carac.Name.ToLower().Equals("battery level") || carac.Uuid == "2a19") { characteristicBattery = carac; } if (carac.Name.ToLower().Equals("temperature measurement") || carac.Uuid == "2a1c") { characteristicTemperature = carac; } } } } if (characteristicTemperature.CanUpdate) { characteristicTemperature.ValueUpdated += (o, args) => { byte[] bytes = args.Characteristic.Value; }; await characteristicTemperature.StartUpdatesAsync(); } if (characteristicBattery.CanUpdate) { characteristicBattery.ValueUpdated += (o, args) => { byte[] bytes = args.Characteristic.Value; }; await characteristicBattery.StartUpdatesAsync(); } //Temperatura if (characteristicTemperature.Uuid == "2a1c" || characteristicTemperature.Name.ToLower().Equals("temperature measurement")) { byte[] byteValues = characteristicTemperature.Value; if (byteValues.Length > 0) { string hexadecimal = BitConverter.ToString(byteValues); string[] hexSplit = hexadecimal.Split('-'); //Temperatura string medicaoHex = "0x" + hexSplit[2] + hexSplit[1]; string result = Convert.ToInt32(medicaoHex, 16).ToString(); string temperatura = result.Substring(0, 2) + "," + result.Substring(2, 2); //Horário string horaHex = "0x" + hexSplit[9]; string minutoHex = "0x" + hexSplit[10]; string segundoHex = "0x" + hexSplit[11]; int hora = Convert.ToInt32(horaHex, 16); int minuto = Convert.ToInt32(minutoHex, 16); int segundo = Convert.ToInt32(segundoHex, 16); TimeSpan horario = new TimeSpan(hora, minuto, segundo); temperature.Text = temperatura + "º"; titleTemperature.Text = "Ultima medição em " + minuto + " minutos"; activeLoad.IsRunning = false; activeLoad.IsVisible = false; frameTemperature.IsVisible = true; } } if (characteristicBattery.CanRead) { if (characteristicBattery.Uuid == "2a19" || characteristicBattery.Name.ToLower().Equals("battery level")) { byte[] byteValues = characteristicBattery.Value; string hexadecimal = BitConverter.ToString(byteValues); int batteryLevel = 0; if (!string.IsNullOrEmpty(hexadecimal)) { string[] hexSplit = hexadecimal.Split('-'); //Bateria string batteryHex = "0x" + hexadecimal; batteryLevel = Convert.ToInt32(batteryHex, 16); } lblBattery.Text = "Nível de bateria: " + batteryLevel + "%"; } } }
iOS 13 breaks tap on push notification
I have implemented push notifications using Xamarin.Forms. When a device receives a push notification, the user can either drag down the notification to reveal Accept/Decline buttons or tap the notification, which will display the Accept/Decline buttons. Everything works fine on devices running iOS 12. However, in iOS 13, I am having an issue on the tap notification, when the app is not running or the device is locked. When a user taps on the notification, the app is supposed to start and display the Accept/Decline buttons, but it never does.
I need some help in resolving this issue. What in iOS 13 changed to break my code?
public override void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, System.Action completionHandler) { App._notificationReceived = true; var dataPayload = response.Notification.Request.Content.UserInfo; string enrollmentId = dataPayload["enrollmentId"] as NSString; string challengeId = dataPayload["challengeId"] as NSString; switch (response.ActionIdentifier) { case "approve-action-click": Xamarin.Forms.Application.Current.MainPage = new NavigationPage(new ApprovalHandlerPage(enrollmentId, challengeId, ChallengeOutcome.Approve)) { BarBackgroundColor = Color.FromHex("276304"), BarTextColor = Color.White }; completionHandler(); break; case "reject-action-click": AccountModule module = new AccountModule(); Task.Run(async () => { await module.AuthorizationChallengeReply(enrollmentId, challengeId, ChallengeOutcome.Decline); completionHandler(); }); break; default: Xamarin.Forms.Application.Current.MainPage = new NavigationPage(new ApprovalHandlerPage(enrollmentId, challengeId, ChallengeOutcome.Unknown)) { BarBackgroundColor = Color.FromHex("276304"), BarTextColor = Color.White }; completionHandler(); break; } }
The "default" in the switch-case handles the tap.
public partial class ApprovalHandlerPage : ContentPage { private ChallengeOutcome _outcome; private int counter = 0; public ApprovalHandlerPage(string enrollmentId, string challengeId, ChallengeOutcome outcome) { InitializeComponent(); _outcome = outcome; this.BindingContext = new ApprovalHandlerViewModel(enrollmentId, challengeId); } protected async override void OnAppearing() { counter++; await (this.BindingContext as ApprovalHandlerViewModel).HandleOutcome(_outcome); } } public class ApprovalHandlerViewModel : BaseViewModel { StorageRepository _storageRepository; private string _enrollmentId; private string _challengeId; private string _accountName; public bool IsApprovalActionRequired { get; set; } public ICommand ApproveCommand { get; set; } public ICommand DeclineCommand { get; set; } public ApprovalHandlerViewModel(string enrollmentId, string challengeId) { _enrollmentId = enrollmentId; _challengeId = challengeId; _storageRepository = new StorageRepository(); GetAccountName(); ApproveCommand = new Command(async () => await HandleOutcome(ChallengeOutcome.Approve)); DeclineCommand = new Command(async () => await HandleOutcome(ChallengeOutcome.Decline)); } public async Task HandleOutcome(ChallengeOutcome outcome) { AccountModule module = new AccountModule(); switch (outcome) { case ChallengeOutcome.Approve: await AuthenticateForApproval(module); break; case ChallengeOutcome.Decline: await module.AuthorizationChallengeReply(_enrollmentId, _challengeId, ChallengeOutcome.Decline); SetRoot(new MainPage()); break; case ChallengeOutcome.Unknown: IsApprovalActionRequired = true; OnPropertyChanged(nameof(IsApprovalActionRequired)); IsApprovalActionRequired = await DisplayAlert("Attention","An action for the account: " + _accountName + " requires your approval. ACCEPT to begin approval or DECLINE to reject","Accept","Decline"); await HandleOutcome(IsApprovalActionRequired ? ChallengeOutcome.Approve : ChallengeOutcome.Decline); break; } } private async Task AuthenticateForApproval(AccountModule module) { ... } public void GetAccountName() { ... } }
create android apps package for Huawei AppGallery.
hi
It’s possible for visual studio 2019 to supports Xamarin create android apps package for Huawei AppGallery.
and can xamarin.Forms supports C#?
Thanks
Tried ALL Xamarin BLE Demo Apps - None of them are working
It's the first time I register for a forum, because I couldn't find a solution somewhere in the internet.
I have an arduino and connected a bluetooth module. The module is a HM10 (i also have the HC08). This bluetooth module is for a bluetooth low energy (ble) connection.
Now I want to build an app for android and iOS which is able to communicate with the arduino over ble.
If I download the app "BLE Scanner" from the Play Store (guess it's written in java) I can connect to the arduino. So I have proof that my arduino setup works.
This is my concept:
1. Finding a working BLE Demo App
2. Looking in the source code and implement it in my own app.
Im searching in the internet for more than 3 months and couldn't find one single working BLE Demo app!!! Why? How in the world is this possible?
There are also many different Plugins for BLE, but none of them works. Can't someone delete this? It's just time wasting!
I tried ALL available Demo Apps in the internet for more than 3 months. Here are some links:
h-ttps://github.com/ricardoromo/BLEArduino/tree/master/BLEArduino
h-ttps://github.com/xabre/xamarin-bluetooth-le
h-ttps://github.com/aritchie/bluetoothle
h-ttps://github.com/xamarin/Monkey.BluetoothLE/tree/master/Sample%20Apps/BLE%20Explorer/BLEExplorer
h-ttps://github.com/nexussays/ble.net
very disappointed --> h-ttps://medium.com/@didourebai/integrate-and-use-the-ble-plugin-for-xamarin-edd6d8a1096d
h-ttps://acaliaro.wordpress.com/2017/02/07/connect-a-barcode-reader-to-a-xamarin-forms-app-via-bluetooth/comment-page-1/
h-ttps://greenfinch.ie/2016-07-06-bluetooth-le/
There were more links...so I'm pretty sure I don't need someone who's answer is just copying another link to a BLE demo app, because I tried them ALL!
Is there anybody who recently build a working Xamarin Forms BLE App? Or is this not possible anymore in Xamarin? I would be so so so thankful if there is someone who can send me his own source code to a real working BLE App.
Thanks in advance!
I'm new here so I couldn't post links, thats why I wrote h-ttps.
Requirements To Build A Simple Chat APP?
I want to build a chatting App. So what are the requirments for it. I mean which server and database will be best for it?Any suggestion plz to build a chatting App?
static proterty / OnPropertyChanged / binding context
Hello,
this is just an example to simplify what my app should do
I have a Data class which contains different instances which must be accessible via binding on the different views
public class Data { private Order _order_obj; public Order Order_obj { set { _order_obj= value; OnPropertyChanged(); } get => _order_obj; } private User _user_obj; public User User_obj { set { _user_obj = value; OnPropertyChanged(); } get => _user_obj; } private string _connection_st; public string Connection_st { set { _connection_st = value; OnPropertyChanged(); } get => _connection_st; } public Data() { User_obj = new User(); Order_obj = new Order(); Connection_st = ""; } bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null) { if (Object.Equals(storage, value)) return false; storage = value; OnPropertyChanged(propertyName); return true; } protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public event PropertyChangedEventHandler PropertyChanged; }
MainPage.xaml.cs
public partial class MainPage : ContentPage { private Data _data_obj; public Data Data_obj // not accessible if it's not static { set { _data_obj = value; OnPropertyChanged(); // don't works if Data_obj is static } get => _data_obj; } public MainPage() { Data_obj = new Data(); Data_obj.Connection_st = "Hello"; } }
MainPage.xaml and OrderPage.xaml
<Label Text="{Binding Data_obj.Connection_st}" />
ConnectionPage.xaml.cs
// clic on Button "log in" private async void ConnectionUser(object sender, EventArgs e) { // call API connection MainPage.Data_obj.User_obj.UpdateInfo(datas); MainPage.Data_obj.Connection_st = "Hello " + MainPage.Data_obj.User_obj.FirstName_st; await Navigation.PushAsync(new MainPage(), false); }
my problems:
- the refresh for the binding does not work correctly when I modify the properties of Data_obj (example:
MainPage.Data_obj.User_obj.Address = newAdress
) - if the Data_obj property is not static: MainPage.Data_obj is not accessible on ConnectionPage or on other ContentPages.
I have done a lot of research and attempting, but the handling of OnPropertyChanged or an "OnGlobalPropertyChanged" escapes me. I think I'm complicating things ...
do you have a simple idea for this basic management? Thank you very much for your advice.
One Signal for Xamarin - how use with Android X?
I using OneSignal(3.10.1) in my Xamarin Forms app. I have problem with android. I use some package I use several packages that need Android X. This is:
-BarcodeScanner.XF
-Xam.Plugins.Android.ExoPlayer
But OneSignal using CompileSdkVersion - Android 9(Api Level 28). When I try install OneSignal in android project(for Android 10) than I get this error:
BarcodeScanner.XF 4.8.0 -> Xamarin.Android.Support.Compat (>= 28.0.0.3) Com.OneSignal 3.10.1 -> Xamarin.Android.Support.CustomTabs 26.0.2 -> Xamarin.Android.Support.Compat (= 26.0.2).
So for the single packages I need Android X for the other ones - Android 9(CompileSdkVersion). How do I solve this problem and is it possible?
How can I change Maps pin color on click and then revert back to red when another pin's clicked?
I have several pins on my map. I have a pin clicked event handler which changes the pin color to blue when clicked. How do I revert the pin's color to red when another pin is clicked? While at the same time changing the other pin's color to blue?
How to Print Bitmap Image as a Logo to Bluetooth Receipt Printer?
Hi,
I am newbie to xamarin forms. I able to print text using this code
try { using (BluetoothSocket bluetoothSocket = device?. CreateRfcommSocketToServiceRecord( UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"))) { if (!bluetoothSocket.IsConnected) { bluetoothSocket?.Connect(); } byte[] buffer = Encoding.UTF8.GetBytes(text); await bluetoothSocket?.OutputStream.WriteAsync(buffer, 0, buffer.Length); Thread.Sleep(1000); bluetoothSocket.Close(); } } catch (Exception exp) { throw exp; }
the problem is the image. everytime i convert the image to byte[] .. it print some weird character. i dont know how to implement this one.
Behavior not detached
Xamarin Forms 4.5.0.495
I have a page with an Entry
. I have a Behavior
attached to the entry.
When I'm pressing the back button to go to the previous page, the OnDetachingFrom
method of the behavior is not called.
How can I resolve this issue?
Xamarin.Auth Possible Forgery Error
Before I ask my question please know that I have seen all of the posts regarding this issue.
I have followed the prescribed method for solving the issue but when I attempt to override OnPageEncountered - it isn't in the library...I'm using 1.6.0.2
Does anyone know of a solution to this...?
many thanks in advance
percy
ISSUE: FTP Request hanging while connected to Mobile Network
Problem: I'm trying to download a file from a dedicated ftp of ours. The FTP request goes through fine on my android device (real device: Galaxy s10) when it is connected to WIFI. When I'm connected to Mobile network it hangs for a few minutes then sends a cannot connect to server error.
What I've Tried: Been working on this for a week or so. When I originally had the issue i tried different versions of Visual Studio 2019. I finally was able to get it work on the Preview version 18.0 preview 3.0. (To be clear, the request would go through on both wifi and mobile network.) I updated the software not thinking about the possibility that the issue may, once again, arise. Now it wont work and i cant downgrade to an old preview (The only version i could get this to work on). I've tried to use WebClient instead of FTPWebRequest. I've also tried to do this request in Passive mode (and without).
My Code:
public static bool DownloadFromFTP(string theuri, string FileDestination)
{
try
{
Int64 currentProg = 0; //1. Create a request: must be in ftp://hostname format, System.Net.FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(theuri); //ftp.UsePassive = true; //<------tried with and without this, also tried with this false //2. Set credentials ftp.Credentials = new System.Net.NetworkCredential(App.ftpLogin, App.ftpPass); //3. Settings and action ftp.KeepAlive = false; //we want a binary transfer, not textual data ftp.UseBinary = true; //Define the action required (in this case, download a file) ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile; ftp.Timeout = 10000;//10 second timeout //5. Get the response to the Ftp request and the associated stream using (System.Net.FtpWebResponse response = (System.Net.FtpWebResponse)ftp.GetResponse()) { using (System.IO.Stream responseStream = response.GetResponseStream()) { //loop to read & write to file using (FileStream fs = new FileStream(FileDestination, System.IO.FileMode.Create)) { byte[] buffer = new byte[2048]; int read = 0; do { read = responseStream.Read(buffer, 0, buffer.Length); fs.Write(buffer, 0, read); currentProg += read; } while (!(read == 0)); responseStream.Close(); fs.Flush(); fs.Close(); } responseStream.Close(); } response.Close(); } return true; } catch (Exception e) { return false; } }
Clarifications: We use this same set of code in multiple points in a PC Software of ours and it has been reliable. Id like to reiterate, i had this working great in a different version of Visual Studio 2019.
So what's different? is it bad code and just a fluke that i got it to work in a certain version? is there a different method of downloading files that will work more consistently? is there a separate permissions I'm missing to allow Cellular network access? Is this a consistent bug in Visual Studio?(I doubt it since this has to be a common thing people do in Apps)
Sorry if i posted this in the wrong place. I don't typically post my problems because there's normally a lot of solutions out there. But i've looked and can't find anything new enough to be relevant to my situation.
Exception thrown: {System.Net.WebException: Unable to connect to the remote server
at System.Net.FtpWebRequest.CheckError () [0x00008] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Requests/src/System/Net/FtpWebRequest.cs:1222
at System.Net.FtpWebRequest.GetResponse () [0x001b0] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Requests/src/System/Net/FtpWebRequest.cs:619
at ''.Services.CommonFunctions.DownloadFromFTP (System.String theuri, System.String FileDestination) [0x00059] in C:\''\''\''\Services\CommonFunctions.cs:103 }
overlap listview item
Hi, i want to show listview item overlap each other, how i achieve this.
ListView ContextAction keyboard accessibility on UWP
With a Xamarin.Forms ListView on UWP, how can the user popup the context menu (the one containing ContextActions) using the keyboard for the currently selected item? I thought it was Shift+F10 (perhaps I'm having brain-fade and have got the wrong key combination), but nothing is happening using XF 3.4 .
How to provide instruction when open the app in xamarin.forms?
I want to provide instruction of the user that how user can use the app.but i did not found any method for instruction.if any one have any method to define instruction when user open the app first time please suggest me for this.i found showcase in android.is there any method in Xamarin forms.
TappedPage
How I can do the TappedPage in Android like the IOS -At the bottom-
Persian calendar
How can I translate Persian?
Why does this Bindable.Layout work in UWP, but not in Android?
Hello Campers
I have this program which uses a Bindable.Layout which works fine in UWP, but not in Android. If you run the program and press "Drink me!" a few times then the beverage list appears and disappears consistently under UWP, but it only appears just the ONCE under the Android emulator. Can any wise owl give me any guidance as to why this should be the case? Many thanks in advance for any light you can shine.
Here is the XAML MainPage.Xaml:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Wonderland.MainPage"> <Frame CornerRadius="25" x:Name="framestack" HasShadow="False" Padding="0" BorderColor="Black" Margin="5,0,5,0"> <StackLayout Spacing="0" Padding="5,0,5,0" Margin="10,0,10,0" BackgroundColor="Transparent"> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="250"/> </Grid.ColumnDefinitions> <Frame Grid.Column="0" CornerRadius="5" HasShadow="False" Padding="0" BorderColor="Red" Margin="0,0,0,0"> <StackLayout Spacing="0" Padding="5,0,5,0" Margin="10,0,10,0" BackgroundColor="Transparent"> <Grid > <Grid.RowDefinitions> <RowDefinition Height="50"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <StackLayout Grid.Row="0" HeightRequest="50"> <Label Text="Drink me!" Margin="10,0,0,0"/> <StackLayout.GestureRecognizers> <TapGestureRecognizer NumberOfTapsRequired="1" Tapped="Submit"/> </StackLayout.GestureRecognizers> </StackLayout> <StackLayout Grid.Row="1" BindableLayout.ItemsSource="{Binding Selections}" IsVisible="{Binding ListVisible}"> <BindableLayout.ItemTemplate> <DataTemplate> <StackLayout> <Label Text="{Binding Content}"/> </StackLayout> </DataTemplate> </BindableLayout.ItemTemplate> </StackLayout> </Grid> </StackLayout> </Frame> </Grid> </StackLayout> </Frame> </ContentPage>
Here is the MainPage.xaml.cs:
using System; using System.Collections.Generic; using Xamarin.Forms; namespace Wonderland { public partial class MainPage : ContentPage { public static MainViewModel mainviewmodel; public MainPage() { InitializeComponent(); mainviewmodel = new MainViewModel(); BindingContext = mainviewmodel; MainViewModel.Brand brand = new MainViewModel.Brand() { Content = "Beer" }; mainviewmodel.BrandSelect.Add(brand); brand = new MainViewModel.Brand() { Content = "Whisky" }; mainviewmodel.BrandSelect.Add(brand); brand = new MainViewModel.Brand() { Content = "Vodka" }; mainviewmodel.BrandSelect.Add(brand); brand = new MainViewModel.Brand() { Content = "Water" }; mainviewmodel.BrandSelect.Add(brand); } public void Submit(object sender, EventArgs e) { if (!mainviewmodel.ListVisible) { mainviewmodel.Selections = mainviewmodel.BrandSelect.ToArray() as dynamic[]; mainviewmodel.ListVisible = true; } else { mainviewmodel.ListVisible = false; } } } }
and here is MainViewModel.cs:
using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; namespace Wonderland { public class MainViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged(string propName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } private bool _listvisible = false; public bool ListVisible { get { return _listvisible; } set { _listvisible = value; this.NotifyPropertyChanged(nameof(ListVisible)); } } public class Brand { public string Content { get; set; } } private List<Brand> _brands_select = new List<Brand>(); public List<Brand> BrandSelect { get { return _brands_select; } set { _brands_select = value; this.NotifyPropertyChanged(nameof(BrandSelect)); } } private dynamic[] _selections; public dynamic[] Selections { get { return _selections; } set { _selections = value; this.NotifyPropertyChanged(nameof(Selections)); } } } }
There are three NuGet packages used:
NetStandard.Library V2.0.3
Xamarin Essentials V1.5.3.2
Xamarin Forms V4.8.0.1451
and the Android target version is Android 9.0 (Pie)