I paint some paths using SKiaSharp and want to save it so that I can open it next time.
but there is over 30thousand points. two many of it.just two lines(path).
Is there any way to save it?
I paint some paths using SKiaSharp and want to save it so that I can open it next time.
but there is over 30thousand points. two many of it.just two lines(path).
Is there any way to save it?
Hi , My app is in general an app that scan QR code and give my clients data about vouchers for user .
It has been rejected last week by apple and I don't understand why ? this is the main function of my app .
{
Your app unlocks or enables additional functionality with mechanisms such as promo codes, data transfer codes, license keys, augmented reality markers, or QR codes, which is not appropriate for the App Store.
}
I have a PostAsync that doesn't return anything and doesn't continue code execution afterwards. I get no error but nothing happens when it reaches PostAsync. My code:
public async System.Threading.Tasks.Task<HttpResponseMessage> LoginAsync(string name, string name2, int sourceid) { var client = InitiateHttpClient(""); var json = JsonConvert.SerializeObject(new { name = name, name2 = name2, sourceid = sourceid, }); var data = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync("myRequestUri", data).ConfigureAwait(false); return response; } HttpResponseMessage httpResponseMessage = await login.LoginAsync(Text1, Text2, Source);
EDIT:
After several seconds (possibly 1-2 minutes) I get Exception Unhandled
System.Threading.Tasks.TaskCanceledException: 'The operation was canceled.'
Hello, I am trying to request to payment gateway server using following code
using (HttpClient client = new HttpClient())
{
FormUrlEncodedContent content = new FormUrlEncodedContent(request);
var response = await client.PostAsync(url, content);
responseString = await response.Content.ReadAsStringAsync();
}
I am getting successful response from payment gateway and I am rendering response string to webview like this..
GatewaySource = new HtmlWebViewSource
{
Html = System.Web.HttpUtility.HtmlDecode(responseString)
};
response have html with loads of Javascript code but javascript is not working/injecting thus I can't go ahead with payment cycle.
Please find attached response file from payment gateway which I ain't able to display properly.
I want when user press 'back button' on android device to exit my app, there is a alert dialog shown to ask user 'Do you want to exit ? (Yes, No)'.
https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.application.pagedisappearing?view=xamarin-forms
I found 'Application.PageDisappearing Event', but I don't know how to write the code.
I have never write the code to work with Event variable.
I need to do the exit alert because my app have TcpClient connection, if the app exit the connection will be disconnect.
I want user use 'home button' to let my app go background, that will be keep the connection alive.
Hi there
I have used RestSharp and wrapped an api into a nice NET Standard library
the library takes username, password and platform as arguments and then api outputs api key which library uses internally it also had data models in it
now it works fine, but I don't know how to integrate it into Xmarin.Forms, where to initiate it to be able to acsess its methods and its data from every xmarin.forms subpage (I am using a AppShell)
if we start with Shell Template that visual studio 2019 provides
should I initiate my API in AppShell.xaml.cs or in App.xaml.cs
but then if I do that in there how would I acsess it in for instance AboutPage View Model (I can make it static but this doesn't seem right and it wierd you have to call AppShell.myApi everytime you want to use an api)?
How would I access it in Xmarin.Android portion (I could use MessageCenter(but I can only call void methods with this I cannot(or don't know how) return data) or I could create some static classes in Xmarin.Forms portion, but I don't know if it is the right approach)
what is the best way to handle exeptions (for now my library only throws Exeption with message: throw new Exception("Message Here"))
API has errors like this:
200 - Request successful. More information is returned in json object. Object schema depends on method.
201 - Request successful. No result returned.
400 - Error occurred. Additional information provided in json response (ErrorResponse format: more info below)
401 - Authentication failure. There are two possible reasons: disabled API access or invalid ApiKey provided
403 - Access forbidden
404 - Invalid method URL
405 - HTTP method not allowed, please verify HTTP method of the request
429 - Too many requests in a given amount of time. API limits are 20 requests/second, 1500 requests/hour, 10000 requests/day
5xx - Something wrong happened in Calamari backend. Please wait a while and repeat your request. If error still occurs, drop us a line.
If status 4xx is returned, you can read additional information from returned json object.
{
"message": string,
"code": string,
"field": string
}
message - Human readable error explanation.
code - Error code. Possible value depends on method but there is few common error codes.
field - Which field of payload object caused error. NULL when error is not related to particular field
What is the best aproach to throw appropriate exeption for this, at the end I would like to show an alert to the user if exeption accures, so my library would trow 500Exeption for instance and user would get an error
how would I do this globally, so I don't need to wrap every button in try/catch block
All theese are more of a design questions that bother me and I don't know where to find anwsers to them, as I never saw an example with Xmarin.Forms and REST api that takes username/password api then sends api key which app uses in all subsequent API requests
Hopefully someone can give me some advice on all this, (particulary how to handle exeption and inform the user and where in the project to construct the api so I can easly acsess it from all subpages)
Thannks for Anwsering and Best Regards
Hi there
I created Master-Detail example app when creating new Xmarin.Forms project
but then I wanted to integrate this login screen: mallibone.com/post/creating-a-login-screen-with-xamarinforms
Now He is using A simple Navigation Service for Xamarin.Forms: mallibone.com/post/a-simple-navigation-service-for-xamarinforms
to show login page and navigate
now the problem is I cannot seem to integrate this into my app
now in the xmarin.forms master-detail page example, main page(app.xaml.cs) it started like this: MainPage = new MainPage();
but the SimpleNavigationService requires the page to be started like this:
_navigationService.Configure(PageNames.LoginPage, typeof(Views.LoginPage)); _navigationService.Configure(PageNames.MainPage, typeof(Views.MainPage)); MainPage = _navigationService.SetRootPage(nameof(Views.MainPage));
if I do that then Hambuger menu navigation doesn't work (I get System.NullReferenceException: 'Object reference not set to an instance of an object.', but it doesn't show where) any more and app looks weird (cannot post picture, but there are 2 hambuerger menu icons it looks like MainPage in MainPage)
Hopefully someone can tell me how I can use A simple Navigation Service for Xamarin.Forms with Master-Detail page (cuz it looks like a neat library)
Thanks for Anwsering and Best Regards
Hello every one i just want to ask how can i make SkiaSharp path fill the page width no matter the size of the screen
this what i got when the app open in bigger screen
this my code
view :
<skisharp:SKCanvasView x:Name="canvsview" PaintSurface="canvsview_PaintSurface" HorizontalOptions="Fill" Margin="0,-15,0,10" WidthRequest="1050" HeightRequest="750" > </skisharp:SKCanvasView>
backend :
private void canvsview_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e) { SKImageInfo info = e.Info; SKSurface surface = e.Surface; SKCanvas canvas = surface.Canvas; // Create new Color var Color = new SKColor(93, 156, 255, 255); // The Gradient's Color List SKColor[] GradientColors = { new SKColor(255, 255, 255, 255), Color, Color }; // The Gradient's Weight List float[] GradientWeights = { 0f, 0.5292227f, 0.9662447f }; // Create new Gradient var Gradient = SKShader.CreateRadialGradient(new SKPoint(80.96484f, 103.4766f), 514.6058f, GradientColors, GradientWeights, SKShaderTileMode.Clamp); // Fill color for Bezier Style var BezierStyleFillColor = new SKColor(230, 230, 230, 255); // New Bezier Style fill paint var BezierStyleFillPaint = new SKPaint() { Style = SKPaintStyle.Fill, Color = BezierStyleFillColor, BlendMode = SKBlendMode.SrcOver, IsAntialias = true, Shader = Gradient }; // Frame color for Bezier Style var BezierStyleFrameColor = new SKColor(253, 253, 253, 255); // New Bezier Style frame paint var BezierStyleFramePaint = new SKPaint() { Style = SKPaintStyle.Stroke, Color = BezierStyleFrameColor, BlendMode = SKBlendMode.SrcOver, IsAntialias = true, StrokeWidth = 1f, StrokeMiter = 4.934776f, StrokeJoin = SKStrokeJoin.Miter, StrokeCap = SKStrokeCap.Butt }; // Define Bezier shape path var BezierPath = new SKPath(); BezierPath.MoveTo(new SKPoint(-91.88669f, 30.0715f)); BezierPath.QuadTo(new SKPoint(-91.60303f, 200.0677f), new SKPoint(-91.31882f, 370.0643f)); BezierPath.QuadTo(new SKPoint(89.03607f, 504.918f), new SKPoint(455.6078f, 373.5671f)); BezierPath.QuadTo(new SKPoint(581.9626f, 307.0941f), new SKPoint(908.1133f, 349.7952f)); BezierPath.QuadTo(new SKPoint(907.4724f, 189.5722f), new SKPoint(906.8309f, 29.34904f)); BezierPath.QuadTo(new SKPoint(485.4685f, 4.917984f), new SKPoint(60.62561f, 20.74986f)); BezierPath.QuadTo(new SKPoint(-91.88669f, 30.0715f), new SKPoint(-91.88669f, 30.0715f)); // Draw Bezier shape BezierStyleFillPaint.Shader = SKShader.CreateRadialGradient(new SKPoint(368.1408f, 298.8855f), 514.6058f, GradientColors, GradientWeights, SKShaderTileMode.Clamp); canvas.DrawPath(BezierPath, BezierStyleFillPaint); canvas.DrawPath(BezierPath, BezierStyleFramePaint); }
Hi there
Whats the easiest way to access the Google Cloud Speech API within Xamarin.Forms?
I tried the following code in my PCL-Project (debugging with an Android-Phone)
Assembly assembly = typeof(Program).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("ConsoleApp1.speech_auth.json"); string resultString = null; using (StreamReader reader = new StreamReader(stream)) { resultString = reader.ReadToEnd(); } GoogleCredential credential = GoogleCredential.FromJson(resultString); if (credential.IsCreateScopedRequired) { credential = credential.CreateScoped(new[] { "https://www.googleapis.com/auth/cloud-platform" }); } var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host, credential.ToChannelCredentials()); var speech = SpeechClient.Create(channel); var response = speech.Recognize(new RecognitionConfig() { Encoding = RecognitionConfig.Types.AudioEncoding.Flac, SampleRateHertz = 16000, LanguageCode = "de-CH", }, RecognitionAudio.FromFile("test.flac"));
However, I get an error message on the line:
var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host, credential.ToChannelCredentials());
which says:
Unhandled Exception: System.NotImplementedException: The method or operation is not implemented
Whats the problem there? Is there any better solution?
On a blank .NET ConsoleApplication, this code is working without problem.
Hello friends, i have main and popup pages.
my architecture is MVVM and i want to call back a string from popup page.
i tried EventHandler . Normally it works but for MVVM i couldnt make it work.
Any ideas?
Thanks in Advance;
I am encountering an error when assigning a new page to a class parameter. It appears that it has not been initialized and is null. What is it and how is it initialized? The code is in the PCL and has no problems in either Android or UWP.
<p>Object reference not set to an instance of an object</p><p>Data ----------</p><p>System.Collections.ListDictionaryInternal</p><p>HResult ----------</p><p>-2147467261</p><p>Source ----------</p><p>Xamarin.Forms.Platform.iOS</p><p>StackTrace ----------</p><p>
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.UpdateMainPage () [0x0000e] in d:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:198 \n at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.ApplicationOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00012] in d:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:152 \n at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 \n at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in d:\a\1\s\Xamarin.Forms.Core\Element.cs:353 \n at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in d:\a\1\s\Xamarin.Forms.Core\Application.cs:91
I added the NotificationContentExtension for the IOS Project in xamarin forms.while building i am getting the below Error.
**Could not find any available provisioning profiles for iOS. NotificationContentExtension.
**
Do we create a new provision profile for this NotificationContentExtension ?
Please help us.
Thanks,
I am trying to remove the cell padding/borders in a Grid. I have read this thread: https://forums.xamarin.com/discussion/23295/can-the-padding-between-rows-in-a-grid-be-changed but none of the methods discussed there allow me to remove the spaces. How do I remove the invisible cell borders?
I've tried :
<Grid.RowDefinitions RowSpacing="0" <Grid.ColumnDefinitions ColumnSpacing="0"
And obviously I've tried Padding="0" in the <Grid
and <Grid.RowDefinitions
and <Grid.ColumnDefinitions
, but no luck.
To make a long story short, the following code crashes my app on startup with System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
It is just a normal property on an object contained in a Listview bound to an ObservableCollection.
private AnswerState _answerState; public new AnswerState AnswerState { get => _answerState; set { Device.BeginInvokeOnMainThread(() => { _answerState = value; OnPropertyChanged(nameof(AnswerStateText)); }); } }
If I remove Device.BeginInvokeOnMainThread() and put it further out, the app runs fine. The exception sure was misleading, and no stacktrace would guide me to find this. In fact, as it happens on startup, I am not even sure if the code in question is even being called before crashing.
I am implementing the theme switcher for iOS 13 from this guide:
https://devblogs.microsoft.com/xamarin/modernizing-ios-apps-dark-mode-xamarin/
I have it working for each time you open the app it will load the correct theme for the given setting, however if I have the app currently running and switch the them it wont hit my breakpoints in the renderer. Is there a way to change themes while app is running?
Thanks
Hi Xamarin Forum
does anyone already used FlowlistView to display images from recorded file path in database and display the image in a tile design just like instagram?
Hello!
Issue: I'm trying to share a folder of web assets to both iOS and Android projects without duplicating them, but I'm having a hard time understanding where they're copying to/where to point my WebView at.
My structure looks like:
MySharedProject
- Content
- data.json
- main.css
- index.html
[...]
MySharedProject.Android
- HybridWebViewRenderer.cs
[...]
MySharedProject.iOS
- HybridWebViewRender
[...]
Backstory: I had the assets in MySharedProject.Android -> Content -> Index.html , etc, then in my WebViewer, I had this code and everything worked.
Control.LoadUrl($"file:///android_asset/Content/{((HybridWebView)Element).Uri}");
I'm trying to take the raw assets out of iOS + Android so I don't have to keep duplicating my efforts when updating them.
1.) Is there a way to create a link/reference between the shared asset and platform assets?
2.) In Android, should I not be using "file:///android_asset/" to reach those assets?
3.) How do you reach copied shared assets from Android and from iOS?
Thanks!
Hi,
I've created a CarouselPage which contains 3 ContentPage. I want to achieve the next functionality:
To do this, I've done the next steps:
in App.xaml.cs:
public App() { InitializeComponent(); if (FirstTimeOpen()) { MainPage = new NavigationPage(new Page1()); } else { MainPage = new MainPage(); } } public bool FirstTimeOpen() { bool isFirstTime = false; var value = Preferences.Get("wasOpened",""); if (value.Equals("true")) { isFirstTime = false; } else { isFirstTime = true; } return isFirstTime; }
and in Page1.xaml.cs:
public Page1() { InitializeComponent(); } public void SetApplicationWasOpened() { Preferences.Set("wasOpened", "true"); } private void Button_Clicked(object sender, EventArgs e) { SetApplicationWasOpened(); Navigation.PushAsync(new MainPage()); }
This works fine but I'd like not to display the navigation bar when I swipe the carousel pages, or at least to color it white.
Thank you!
I've added the font icons as described in this blog post: https://montemagno.com/using-font-icons-in-xamarin-forms-goodbye-images-hello-fonts/
Tried ImageButton and Button when FontImageSource is set to some icon in the ttf and I got pretty much the same result (the icon is slightly bigger when using ImageButton)
Which one should I choose when I don't care much about the size differences?