Hello,
for my app i look for a solution how can i use the Flic 2 (Schortcutlab) Blutooth button in Xamarin (c# / android project) with Visual Studio 2017/2019.
Have everybody a solution for me?
Hello,
for my app i look for a solution how can i use the Flic 2 (Schortcutlab) Blutooth button in Xamarin (c# / android project) with Visual Studio 2017/2019.
Have everybody a solution for me?
Is there any way to get Mac Address in Xamarin.forms?
Is there any example?
I am interested to get any sound currently playing on a mobile device, even if it is not playing using the app. Is it possible to monitor the speakers, and get data directly before they play that sound? Like when you plug in the headphones and the speaker stops, but android sends the data to the headset, no matter, where it is playing. If it is, what would be the code?
I did look at this, but this should get only if it is playing or not, and not actuall song data.
hi
An example can let
Hello,
i'm trying to set a minimum value for a slider:Slider slider = new Slider { Minimum = 30.0, Maximum = 60.0, Value = 45.0 };
This results in an exception:
System.ArgumentException: Value was an invalid value for Minimum Parameter name: value
I can set the minimum without problems to zero or a negative value, but a value greater than zero throws the error.
Is this working as intended or a bug?
Regards,
Dirk
Hi, i am using Xamarin form through Api.Sql Server.
the thing is when i log in my App , and showing my customer number from my data table.
like
i want to make Log in phone number, password, and then showing customer number to my app page.
that is my code below,
public async void SignInProcedure(object sender, EventArgs e) {
User user = new User(Entry_phone.Text, Entry_Password.Text); if (user.CheckInformation()) { HttpClient client = new HttpClient(); var uri = new Uri(string.Format("http://4a99cffe.ngrok.io/api/Login?phone=" + Entry_phone.Text + "&password=" + Entry_Password.Text)); HttpResponseMessage response; ; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); response = await client.GetAsync(uri); if (response.StatusCode == System.Net.HttpStatusCode.Accepted) { var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1] { '"' }); await DisplayAlert("Login", "Log in success", "ok"); await Navigation.PushAsync(new Customerinfo(Entry_phone.Text)); } else { var errorMessage1 = response.Content.ReadAsStringAsync().Result.Replace("\\", "").Trim(new char[1] { '"' }); await DisplayAlert("Login", "", "Again"); } Entry_phone.Text = string.Empty; Entry_Password.Text = string.Empty; } else { await DisplayAlert("Login", "Not correnct Login information", "ok"); }
That is my api
[HttpGet] [ActionName("XAMARIN_Login")] public HttpResponseMessage Xamarin_Login(string phone, string password) { var user = db.customers.Where(x => x.Phone == phone && x.Password == password).FirstOrDefault(); if (user == null) { return Request.CreateResponse(HttpStatusCode.Unauthorized, "Please Enter valid UserName and Password"); } else { return Request.CreateResponse(HttpStatusCode.Accepted, "Success"); } }
i want to make Log in phone number, password, and then showing my my customer number to my page.
Is it possible to remove the border of selected items in multiple selection mode of collection view in UWP?
Every now and again you find a topic where you say "I know I'm not the first to ask this" but can't find any current conversation or resolution. This seems to be one of those. I'm not a web guy, so maybe this is something everyone knows through growing up in it but just seems to be uncovered for 2018 and Xamarin Forms >= 2.5
All I want to do is have my app open a web page that wants basic HTTP authentication.
There are countless articles from 2014 on doing this.
https://forums.xamarin.com/discussion/42918/how-to-access-protected-resource-using-xamarin-webview-basic-authentication
The implementation here is really straightforward with a nice username and password property you can set in XAML even.
And a good Nuget for an authenticating webview
https://github.com/TheRealAdamKemp/AuthenticatedWebView/issues/3
However all of these answers I'm finding for Xamarin forms less than 2.5. Those same bits of solution do not work with the WebView
of 2.5 and later. When I say 'Does not work' I mean two things mostly:
1) The code makes use of obsoleted constructor and method syntax. That seems to have been an easy hurdle but maybe I'm wrong.
2) The method needed for passing the credentials (OnReceivedHttpAuthRequest
) is never hit in XF3.3. So if the WebView
doesn't run this override you never get to send the username/password.
I can't believe I'm the first person to want to do this basic function. Or felt pain when XF1.3 was replaced by 2.5 and it stopped working.
I have to believe I just don't know some basic thing that everyone else knows like "Use the blah blah control" or whatever. But I'm in this a week now and can't seem to make the working solutions I've found from 1.3 work in modern 3.3
Here's my updated version of code from the 2015 thread - maybe someone with more web experiences spots something obvious.
using System; using Android.Content; using Android.Webkit; using Xamarin.Forms; using WebView = Xamarin.Forms.WebView; [assembly: ExportRenderer(typeof(AuthWebView), typeof(AuthWebViewRenderer))] namespace SysUtilityPFX.Droid.Common { public class AuthWebViewRenderer : Xamarin.Forms.Platform.Android.WebViewRenderer { AuthWebViewClient _authWebClient = null; public AuthWebViewRenderer(Context context) : base(context) { var breakpointable = 5; } /// <summary>Syntax obsolete since XamForms 2.5 /// /// </summary> /// <param name="e"></param> protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<WebView> e) { base.OnElementChanged(e); if (_authWebClient == null) { _authWebClient = new AuthWebViewClient("admin", "admin");//Testing to make it work then make it better afterwards. //_authWebClient = new AuthWebViewClient(AuthWebView.Username, AuthWebView.Password);//Error Object reference for static } Control.SetWebViewClient(_authWebClient); } } public class AuthWebViewClient : WebViewClient { private string Username { get; } private string Password { get; } public AuthWebViewClient(string username, string password) { Username = username; Password = password; } //Never hits breakpoint public override void OnReceivedHttpAuthRequest(global::Android.Webkit.WebView view, HttpAuthHandler handler, string host, string realm) { handler.Proceed( Username, Password); } [Obsolete("deprecated")] public override bool ShouldOverrideUrlLoading(global::Android.Webkit.WebView view, string url) { view.LoadUrl(url); return true; } } } /* References https://forums.xamarin.com/discussion/42918/how-to-access-protected-resource-using-xamarin-webview-basic-authentication https://www.ozkary.com/2018/06/xamarin-android-webview-authentication.html https://xamarinexplorer.com/2018/01/20/adding-authorization-header-in-web-view/ iOS only https://github.com/TheRealAdamKemp/AuthenticatedWebView/issues/3 XF 1.3 version works great. Not in 2018 with XF3.3 */
Hi, I want to implement logic to my xamarin.Forms application (for android and Ios), which sends notification to user when something new appears in database. For example when other user add an invitation to database, invited user will receive it. Thanks
Hi,
I'm trying to find a package that can scan a QR code from a saved image on a mobile device (not from a live camera).
I have successfully implemented ZXing to scan QR codes from a live camera.
To make matters simple, if I have an image saved on a page, how can I then scan this image containing a QR code inside. Assume that the XAML code for the image on this page is simply:
[code]
[/code]
I can't seem to get any progress and would appreciate any help.
There is two ways to put items into the top part of a Shell application,. I can use <ContentPage.ToolbarItems> or I can <Shell.TitleView>. Both of them lives inside a ContentPage and will therefore not live the lifetime of the application. Is there any way to put items into the top part that stays all the application life time, for example created from the shell?
I am working with Xamarin Forms on a message sending application with SignalR, which I have tested countless times locally and on Android and it works fine without crashes, but when they do the tests to upload it to the microsoft store they report that my application crashes .
According to the App center, the application crashes when they trying to send a message through SignalR, this is the error:
< SendPrivateMessageAsync> d__46.MoveNext () + 0x14b System.Reflection.MissingMetadataException: This operation cannot be carried out because metadata for the following object was removed for performance reasons:\n\n EETypeRva:0x0035FCD8\n\nNo further information is available. Rebuild in debug mode for better information.\n\n
System.Reflection.Runtime.TypeInfos RuntimeNoMetadataNamedTypeInfo.get_InternalFullNameOfAssembly () f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\TypeInfos\RuntimeBlockedTypeInfo.cs at 240:17 System.Text.Json JsonPropertyInfo.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x11f System.Text.Json JsonPropertyInfoCommon`4.Initialize (Type, Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x:59 System.Text.Json JsonClassInfo.CreateProperty (Type, Type, Type, PropertyInfo, Type, JsonConverter, JsonSerializerOptions) + 0x2f:2 System.Text.Json JsonClassInfo.AddProperty (Type, PropertyInfo, Type, JsonSerializerOptions) + 0x9e System.Text.Json JsonClassInfo.AddPolicyProperty (Type, JsonSerializerOptions) + 0x2f System.Text.Json.JsonClassInfo + 0xdd:1 System.Text.Json JsonSerializerOptions.GetOrAddClass (Type) + 0x:71 System.Text.Json WriteStackFrame.Initialize (Type, JsonSerializerOptions) + 0x:13 System.Text.Json JsonSerializer.WriteCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x8d System.Text.Json JsonSerializer.WriteValueCore (Utf8JsonWriter, Object, Type, JsonSerializerOptions) + 0x3e Microsoft.AspNetCore.SignalR.Protocol JsonHubProtocol.WriteArguments (Object[], Utf8JsonWriter) + 0x1ef Microsoft.AspNetCore.SignalR.Protocol JsonHubProtocol.WriteStreamInvocationMessage (StreamInvocationMessage, Utf8JsonWriter) + 0x:65 Microsoft.AspNetCore.SignalR.Protocol JsonHubProtocol.WriteMessageCore (HubMessage, IBufferWriter`1) + 0x55d Microsoft.AspNetCore.SignalR.Protocol JsonHubProtocol.WriteMessage (HubMessage, IBufferWriter`1) + 0xc Microsoft.AspNetCore.SignalR.Client.HubConnection <SendHubMessage>d__72.MoveNext () + 0x7f System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70 System.Runtime.CompilerServices TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38 System.Runtime.CompilerServices TaskAwaiter.ValidateEnd (Task) + 0x:17 System.Runtime.CompilerServices TaskAwaiter.GetResult () + 0xb Microsoft.AspNetCore.SignalR.Client.HubConnection <InvokeCore>d__70.MoveNext () + 0x:194 System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70 System.Runtime.CompilerServices TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38 System.Runtime.CompilerServices TaskAwaiter.ValidateEnd (Task) + 0x:17 Microsoft.AspNetCore.SignalR.Client.HubConnection <InvokeCoreAsyncCore>d__69.MoveNext () + 0x:335 System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70 System.Runtime.CompilerServices TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38 System.Runtime.CompilerServices TaskAwaiter.ValidateEnd (Task) + 0x:17 System.Threading.Tasks ForceAsyncAwaiter`1.GetResult () + 0x:18 Microsoft.AspNetCore.SignalR.Client.HubConnection <InvokeCoreAsync>d__56.MoveNext () + 0x:105 System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70 System.Runtime.CompilerServices TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38 System.Runtime.CompilerServices TaskAwaiter.ValidateEnd (Task) + 0x:17 System.Runtime.CompilerServices TaskAwaiter.GetResult () + 0xb Chat.Shared.Core.ChatService <SendPrivateMessageAsync>d__46.MoveNext () + 0x14b System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices TaskAwaiter.ThrowForNonSuccess (Task) + 0x:70 System.Runtime.CompilerServices TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task) + 0x:38 System.Runtime.CompilerServices TaskAwaiter.ValidateEnd (Task) + 0x:17 System.Runtime.CompilerServices TaskAwaiter.GetResult () + 0xb MyClinicalApp.ViewModels.ChatViewModel.<>c__DisplayClass39_1 <<SendMessage>b__1>d.MoveNext () + 0x:137 System.Runtime.ExceptionServices ExceptionDispatchInfo.Throw () + 0x:21 System.Runtime.CompilerServices.AsyncMethodBuilderCore <>c.<ThrowAsync>b__7_0 (Object) + 0x1e System Action`1.Invoke (T) + 0x:28 System.Threading.WinRTSynchronizationContext Invoker.InvokeCore () + 0x:33 System.Runtime.InteropServices McgMarshal.ThrowOnExternalCallFailed (Int32, RuntimeTypeHandle) + 0x:21 __Interop ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32) + 0xb:8 __Interop ForwardComStubs.Stub_15[TThis] (__ComObject, Int32) + 0x:24 Microsoft.AppCenter.Utils ApplicationLifecycleHelper.<ctor>b__17_1 (Object, UnhandledErrorDetectedEventArgs) + 0x3d
If someone can give me any tips or advice on how to determine the error. thank you.
P.S. I have also tried Upload debug symbols but I think there is an error in the app center page or I'm probably doing something wrong, the problem is that after about 20min trying to upload the page is cleaned and nothing was ever uploaded, this process will I have tried 7 times and I never manage to upload the .appxsym
I'm trying to bind an enum to Picker control and display localized names to the user. I use the same code that works perfectly in my WPF app, but for some reason it doesn't work in Xamarin Forms and it displays enum's named constants instead of localized names. It looks like that TypeConverter is not called. I checked that the type converter works as expected: TypeDescriptor.GetConverter(typeof(Country)).ConvertTo(Country.sr, typeof(string)) as string; returns localized name.
Here is my type converter class
public class EnumDescriptionTypeConverter : EnumConverter { public EnumDescriptionTypeConverter(Type type) : base(type) { } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (value != null) { FieldInfo fi = value.GetType().GetField(value.ToString()); if (fi != null) { var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); return ((attributes.Length > 0) && (!String.IsNullOrEmpty(attributes[0].Description))) ? attributes[0].Description : value.ToString(); } } return string.Empty; } return base.ConvertTo(context, culture, value, destinationType); } }
and my DescriptionAttribute class
public class LocalizedDescriptionAttribute : DescriptionAttribute { ResourceManager _resourceManager; readonly string _resourceKey; public LocalizedDescriptionAttribute(string resourceKey, Type resourceType) { _resourceManager = new ResourceManager(resourceType); _resourceKey = resourceKey; } public override string Description { get { string description = _resourceManager.GetString(_resourceKey); return string.IsNullOrWhiteSpace(description) ? string.Format("[[{0}]]", _resourceKey) : description; } } }
and my enum
[TypeConverter(typeof(EnumDescriptionTypeConverter))] public enum Country { [LocalizedDescription("sl", typeof(Resource))] sl, [LocalizedDescription("sr", typeof(Resource))] sr, [LocalizedDescription("th", typeof(Resource))] th }
Hello,
I'm new to Xamarin Android programming and I'm really stuck at a WebView implementation. I followed every step of Microsoft's doc and I cannot get the "Invoke Javascript" bit to work.
Here's my HTML file:
<html> <body> <script type="text/javascript"> function factorial(num) { if (num === 0 || num === 1) return 1; for (var i = num - 1; i >= 1; i--) { num *= i; } return num; } </script> </body> </html>
Here's a code snippet on Xamarin:
var webView = new Xamarin.Forms.WebView(); webView.Source = "http://server/testFunction.html"; ////webView.Source = source; var nome = todoItem.Nome; var codpostal = todoItem.CodigoPostal; var email = todoItem.Email; var telefone = todoItem.Telefone; var resultstring = ""; var lojacliente = todoItem.Loja; int number = int.Parse("2"); try { string result = await webView.EvaluateJavaScriptAsync($"factorial({number})"); resultstring = $"Factorial of {number} is {result}."; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("", ex.InnerException.Message, "OK"); }
No matter what I do I always get this exception:
{System.NullReferenceException: Object reference not set to an instance of an object. at Xamarin.Forms.WebView+<EvaluateJavaScriptAsync>d__21.MoveNext () [0x00067] in D:\a\1\s\Xamarin.Forms.Core\WebView.cs:98
What am I doing wrong? I'm used to desktop app programming (Visual Basic) and I'm new to this so I'm really stuck and appreciate any help.
Many thanks in advance.
Hello I'm relatively new to Xamarin form but was just wondering how i can access a image i have in one of my xaml pages which is saved to x:name="MyImage" in another page. I have the x:name in my MainPage.xaml but wish to show the image inside the Cam.Xaml page.
Hello
my application is connected to some web services it works fine before but lately IOS project receive the response with a Status code 200. but in Android statuscode 401 'Unauthorized' same code for both IOS and ANDROID
credCache.Add(new Uri("------"), "Digest", new NetworkCredential("user", "password")); var HttpHandler = new HttpClientHandler(); HttpHandler.Credentials = credCache; var httpClient = new HttpClient(HttpHandler); var answer = httpClient.GetAsync(new Uri(app.Properties["endPoint"].ToString() + "isa_student/list_parameters/param")).Result; --> answer.EnsureSuccessStatusCode();
in this line a get this message bellow
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers: { Date: Thu, 09 Jan 2020 08:57:45 GMT Server: Apache/2.2.22 Server: (Debian) WWW-Authenticate: Digest realm="mydata-api.epf.fr", domain="/", qop=auth, algorithm=MD5, nonce="f6774c3386519e296fc6d5124380390a", opaque="94619f8a70068b2591c2eed622525b0e" Vary: Accept-Encoding Content-Length: 59 Content-Type: text/html }
Thank you for helping it's urgent
Hi,
I have a Xamarin.Forms application with FontAwesome for iOS & Android. Now I
want to use it in macOS also.
I added this to the Info.plist
:
<key>Fonts provided by application</key> <array> <string>FontAwesome5Regular.otf</string> <string>FontAwesome5Solid.otf</string> </array>
In my App.xaml
I use this:
<OnPlatform x:Key="FontAwesomeBrands" x:TypeArguments="x:String"> <On Platform="Android" Value="FontAwesome5Brands.otf#Regular" /> <On Platform="iOS" Value="FontAwesome5Brands-Regular" /> <On Platform="macOS" Value="FontAwesome5Brands-Regular" /> </OnPlatform> <OnPlatform x:Key="FontAwesomeSolid" x:TypeArguments="x:String"> <On Platform="Android" Value="FontAwesome5Solid.otf#Regular" /> <On Platform="iOS" Value="FontAwesome5Free-Solid" /> <On Platform="macOS" Value="FontAwesome5Free-Solid" /> </OnPlatform> <OnPlatform x:Key="FontAwesomeRegular" x:TypeArguments="x:String"> <On Platform="Android" Value="FontAwesome5Regular.otf#Regular" /> <On Platform="iOS" Value="FontAwesome5Free-Regular" /> <On Platform="macOS" Value="FontAwesome5Free-Regular" /> </OnPlatform>
Could it be that the FontFamlily names other on macOS?
I checked that the font is in Resource folder in the macOS project and it is defined as BundleResource
.
Thanks and greets,
Johann
The below code is for custom webview renderer for UWP :
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
var customWebView = Element as PdfView;
Control.Source = new Uri(string.Format("ms-appx-web:///pdfjs/web/viewer.html?file={0}", string.Format(customWebView.Uri)));
}
But this method is looping round(Executing multiple times). Any suggestion please................
I have started using the new Xamarin.Forms checkbox rather than my old implementation and have hit a snag when using a checkbox within a ListView. My test ListView is set up as
<ListView SeparatorVisibility="None" ItemsSource="{Binding SubsistenceDays}" HasUnevenRows="true" BackgroundColor="Transparent"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ContentView BackgroundColor="Transparent" Padding="10"> <CheckBox Color="{Binding BreakfastStatusColour}" IsChecked="{Binding BreakfastAuthorised}" HorizontalOptions="Center" /> </ContentView> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
The checkbox seems to be able to pickup the check state but is always the 'default' colour. My binding is in the 'SubsistenceDay' object and has the following property
public Xamarin.Forms.Color BreakfastStatusColor => (BreakfastAuthorised == BreakfastClaimed) ? Xamarin.Forms.Color.Green : Xamarin.Forms.Color.Yellow;
Seems simple enough but doesn't work and I'm not sure why this is different to the check state which is a simple property
public bool BreakfastAuthorised { get; set; }
Hi I am using DisplayActionSheet I want to add background color of Title. I also want to change selected default color of button.