Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 89864 articles
Browse latest View live

AudioManager Issue...

$
0
0

I need turn on the speaker when the call state is equal to offhook...
I add permission into the manifiest like this:
And... i'm using this code to try turn on the speaker...

AudioManager audioManager = (AudioManager)Android.App.Application.Context.GetSystemService(Context.AudioService);
audioManager.Mode = Mode.InCall;
audioManager.SpeakerphoneOn = true;

The proccess makes a call saccessfully... but the speaker doen't work. It is turn off...

What's the issue here? Thanks!


Events are not uploading for XamarinForms iOS in firebase

$
0
0

I have implemented the firebase anlytics in my xamarin froms app. Events are uploaded and i can see events in firebase console for android.

the problem with ios is, while uploading the event is firebase i am getting this error in output window

NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, NSErrorFailingURLStringKey=https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, NSErrorClientCertificateStateKey=0}
2020-07-31 16:42:05.289718+0530 TitleSnap.iOS[13584:207227] [GoogleDataTransport][I-GDTCOR000002] There was an error uploading events: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,

Because of this events are not uploaded in firebase and able to see the events in friebase console for firebase. Please help me to fix this issue,

Change button more in Shell APP

$
0
0

How to change this more label for menu

How to Reduce Flyout Width in Shell Xamarin.Forms

$
0
0
How to Reduce Flyout Width in Shell Xamarin.Forms

iOS await Shell.Current.GoToAsync(route) hangs forever

$
0
0

Thus far, my experience trying to make Xamarin.Forms work on iOS has been a complete failure, and I am getting very close to giving up on this.

For the past week, I have tried, to no avail, to get push notifications working with both Azure and Firebase, and neither works no matter what I do.

So today, I was hoping to make some progress in at least getting the app to run on iOS, even if notifications can't work.

Alas, here I am, stuck again.

This time, it's on a really simple shell navigation.

The app flow is really basic, the shell is configured to display a "loading" view as the initial page. This page does a quick check to see if the user has already opened the app before, and if so, directs navigation to one page, and if not, to another.

The route in question is a global route registered as follows:

public partial class AppShell : Shell
{
    public AppShell()
    {
        InitializeComponent();
        Routing.RegisterRoute("login", typeof(Login));
        Routing.RegisterRoute("register", typeof(Register));
        Routing.RegisterRoute("botflow", typeof(BotFlow));
        Routing.RegisterRoute("document", typeof(Document));
    }
}

Specifically, the route being navigated to is the "register" route.

The code to perform the navigation is as follows:

public async Task ShellNavigateAsync(string route)
{
    await Task.Run(() =>
    {
        Application.Current.Dispatcher.BeginInvokeOnMainThread(async () =>
        {
            await Shell.Current.GoToAsync(route);
        });
    });
}

The call to await Shell.Current.GotToAsync(route) just hangs forever, and the navigation never takes place.

Hoping someone here can tell me the secret ingredients to make this work.

This code resides in the shared library, btw, and it is working flawlessly on Android. The same can't be said for iOS, sadly.

How to upload a file from a Xamarin.Forms app to DropBox or OneDrive?

$
0
0

Has anybody implemented uploading a file from a Xamarin.Forms app to either DropBox or OneDrive? If so, could you share how you did it please? If you used a third-party component, which one (and would you use the same one again if you were to re-do that task)?

Many thanks,

John H.

XAML-based page crashing in UWP

$
0
0

As part of the training at Evolve 2016, the very basic app we developed was demonstrated on Android and iOS several times, and I tested it as well on my Android tablet. All was well and good. However, at the end I wanted to see it run on UWP on my Windows 10 laptop, but it wasn't working.

It showed the initial page just fine (a programmatic, non-XAML page), but displaying the XAML-based page caused it to just crash. Running it from Visual Studio, it stopped on a file not found exception and while there was no stacktrace, I had taken out any file IO from my app and using Debug.WriteLine, I managed to track it down to the call to InitializeComponent() in the code-behind for the XAML-page.

Neither trainer in my class could come up with an explanation other than UWP support was perhaps still in preview status, but they thought it ought to have worked and that it may be a bug.

I'm not really sure where to go from here, so anyone here know of this problem?

Bind a function on an item of a ListView

$
0
0

This is my starting point:

  • a DataModel Product which has some parameters like quantity, cost, type
  • a ViewModel which loads a list of products
  • a ContentPage which show the products in a ListView, the BindingContext is the ViewModel above

For each product I would like to show some fields like name, quantity, cost... and a calculated field which multiply quantity and cost, but also could have additional logic based on type or user parameters.
I could easily add a new field with only a getter "CalculatedCost" in the Product DataModel, but I don't like very much this, because I'd prefer keep the logic of this calculation outside.

The second idea is to create a static Converter to calculate this, but as far as I now, I could only pass a specific parameter to the converter, while I should make a calculation on the whole model, so how could I pass the whole object from the ListView item?
{Binding ??, Converter={StaticResource costCalculationConverter}}

Third idea, could I call a function of the ViewModel, passing the current Product in the list?

Any other idea to achieve this?
Thanks


Isn't a Xamarin.Forms UWP app targeted to use .NET Core?

$
0
0

I am implementing Dropbox API. I succeeded in both Android and iOS. But in UWP the app is crashing after entering credentials. I see the following two lines in Output window. Isn't Xamarin.Forms.UWP app configured to use .NET Core? If not how can I set it?

Actually after entering the credentials, it asks "Do you want to switch apps". It hangs if I say NO and crashes if I say Yes. I am using "com.companyname.appname:/oauth2redirect" as the Redirect URI and UWP Package Name is set to "com.companyname.appname".

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[26140] WWAHost.exe' has exited with code 1 (0x1).

Xamarin Multple Errors | Can't Archive HelloWorld APK

$
0
0

First of all it takes 5 mints to archive,

And whenever I Build or archive, Xamarin won't able to do it,

I tried reinstall windows + xamarin + Visual studio

Also tried to find answer on different forums,
Didnt get anything,
Even I don't change any code in helloworld apk.

My information:

Mode = Release
Target Framework = Android 9.0 PIE

Error1:The executable is not a valid application.

Occurs = Win_10/7_x86_bit + Visual_Studio 2019:

Unhandled exception: System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Xamarin.Android.Tasks.CompileNativeAssembly.RunAssembler(Config config)
   at Xamarin.Android.Tasks.AsyncTaskExtensions.<>c__DisplayClass0_1`1.<WhenAll>b__0()  App8.Android            
Error       Unhandled exception: System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Xamarin.Android.Tasks.CompileNativeAssembly.RunAssembler(Config config)
   at Xamarin.Android.Tasks.AsyncTaskExtensions.<>c__DisplayClass0_1`1.<WhenAll>b__0()  App8.Android            

1>------ Build started: Project: App8, Configuration: Release Any CPU ------
1>App8 -> C:\Users\Administrator\source\repos\App8\App8\App8\bin\Release\netstandard2.0\App8.dll
2>------ Build started: Project: App8.Android, Configuration: Release Any CPU ------
2>  App8.Android -> C:\Users\Administrator\source\repos\App8\App8\App8.Android\bin\Release\App8.Android.dll
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000: Unhandled exception: System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at System.Diagnostics.Process.Start()
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at Xamarin.Android.Tasks.CompileNativeAssembly.RunAssembler(Config config)
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at Xamarin.Android.Tasks.AsyncTaskExtensions.<>c__DisplayClass0_1`1.<WhenAll>b__0()
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000: Unhandled exception: System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at System.Diagnostics.Process.Start()
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at Xamarin.Android.Tasks.CompileNativeAssembly.RunAssembler(Config config)
2>C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2447,3): error XA0000:    at Xamarin.Android.Tasks.AsyncTaskExtensions.<>c__DisplayClass0_1`1.<WhenAll>b__0()
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Error2:The executable is not a valid application.

Occurs = Win_7_x86_bit + Visual_Studio 2017:

It was building archive before but not works now.

"java.exe" exited with code 1.  App10.Android           
1>------ Build started: Project: App10, Configuration: Debug Any CPU ------
1>App10 -> C:\Users\Administrator\source\repos\App10\App10\App10\bin\Debug\netstandard2.0\App10.dll
2>------ Build started: Project: App10.Android, Configuration: Debug Any CPU ------
2>  App10.Android -> C:\Users\Administrator\source\repos\App10\App10\App10.Android\bin\Debug\App10.Android.dll
2>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
2>C:\Program Files\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2610,3): error MSB6006: "java.exe" exited with code 1.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I will never use Xamrin again in my life,
But due to my project is based on it(libvlcsharp),
Feel free to ask any info If I didn't added it. Thanks.

In a XF app DisplayAlert is hanging in UWP project?

$
0
0

DisplayAlert is hanging only in UWP and only in one app. Other apps don't have any issue. Even for this app no issues with Android and iOS.

I am calling it as follows:

await DisplayAlert("Pick a Photo", "No photo selected.", "OK");

What is missing here?

MVVM Navigation: How to navigate to "Next Quiz" or "Previous Quiz" using only one view?

$
0
0

Each quiz in my app is a unique MVVM object, and all of them lead to the same ResultsPage view. I'd like to have two buttons on this page, so users can navigate to next quiz or the previous one. However, how can I accomplish this given that the ResultsPage is the same view?

I tried passing a variable representint each page as a parameter from each ViewModel, "NQ" (for Next Quiz) and "PQ" (for Previous Quiz), but when I do the "NavigationPage page = new NavigationPage(new NQ())" in the ResultsPage this doesn't seem to work. Here's what I tried in detail. Thank you!

Quiz1 View Model

//...
NQ = Quiz2;
PQ = Quiz0
}

    private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new ResultsPage(PQ, NQ));

}

}


ResultsPage.xaml.cs

public ResultsPage(string PQ, string NQ)
{ this.NQ = NQ;
this.PQ = PQ;
//...

private void NextQuiz(object sender, EventArgs e)
{
NavigationPage page = new NavigationPage(new NQ());
App.Current.MainPage = page;

    }

    private void PreviousQuiz(object sender, EventArgs e)
    {
        NavigationPage page = new NavigationPage(new PQ));
        App.Current.MainPage = page;
    }

Need advice on my project

$
0
0

Hi, I am working on my project that will involve an app sending/receiving information from my database on the web, but I have no idea how to make it work. After some research it appears that I can use a Web API and a SQL server, but I still don't know the path that I have to take to achieve this.

Can someone please tell me how to:

  • Code an API
  • Connect the app with the API
  • Connect the API to the SQL server
  • Send and receive data from the app

Thank you so much for your help!

How to get normal full path to file with FilePicker?

$
0
0
Hello Xamarin Community!
I pick file with FilePicker, but FilePicker not return normal file path. When I try write new text to file error happens.

How do I get the string result of EvaluateJavascript Xamarin Forms?

$
0
0

Hello,

i want to get the value of input field from an html site and tried to use this:
string x = webView.EvaluateJavaScriptAsync("document.getElementById('test').value;")

this is not working, can anyone help me??

Thanks


Databinding Source

$
0
0

Hi,

I want to set a string in another class say App.Xaml.cs

public string MyValue = "somevalue";

How can i bind the text of a label to that MyValue item? I'm not sure how the Databinding source works or how I need to wire it up.

I've tried this which didnt work

Can't see Photos Permission - Xamarin Forms iPhone

$
0
0

Hi,
I have set the Privacy - Photo Library Usage Description property and text in the Info.plist file but it doesn't seem to be working - by that I mean I can't see Photos when I goto Settings > MyApp

I have Privacy - Location When in Use Usage Description set and that works fine (i.e. it shows up in iphone settings for the app)

Bundle Name, Version, Identifier all match up and I'm not sure what else i'd need to set.

Any ideas how to fix? It was working previously - i have recently signed up to Apple Developer / Connect instead of the free profile, so have had to create a bundle ID, App name etc. so not sure if that has caused this.

How to save a SkiaSharp drawing?

$
0
0

I must be missing something. I started with the FingerPainting part of the TouchTrackingEffectDemos. After drawing something, I want to save it so I added a Save Button (just like there is a Clear Button). The Save button is supposed to save the drawing to my device but all I get is a blank white jpg. I am using Snapshot to capture the image. I suspect that it is not working the way I expect.
Here is my code for the Save. Any insight into how to save the drawing to a file is much appreciated!

`
void OnSaveButtonClicked(object sender, EventArgs args)
{
int width = (int)canvasView.CanvasSize.Width;
int height = (int)canvasView.CanvasSize.Height;
var info = new SKImageInfo(width, height);

        var item = (FingerPaintPage)((Button)sender).BindingContext;

        using (var surface = SKSurface.Create(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul))
        {
            SKData skData = surface.Snapshot().Encode();

            IFolder folder = FileSystem.Current.LocalStorage;
            string path = folder.Path;
            string fileout = path + "/outfile.jpg";
            string fileout2 = path + "/outfile2.jpg";

            // Plan A)
            using (Stream stream2 = File.OpenWrite(fileout))
            {
                skData.SaveTo(stream2);
            }        

            // Plan B)
            SKBitmap bitmap = new SKBitmap(width, height);
            // create an image and then get the PNG (or any other) encoded data
            using (var image = SKImage.FromBitmap(bitmap))
            using (var data = image.Encode(SKEncodedImageFormat.Jpeg, 100))
            {
                // save the data to a stream
                using (var stream = File.OpenWrite(fileout2))
                {
                    data.SaveTo(stream);
                }
            }
        }
    }`

Shell for first app?

$
0
0

Hi

In my very first app for Xamarin I need a relatively simple app UI wise with burger menu and single pages leading from burger menu options.

Is xamarin.forms shell the way to go for me?

Thanks

Regards

Master page displaying backgroundImage in iOS but not in Android Project ?

$
0
0

`<?xml version="1.0" encoding="UTF-8"?>

<MasterDetailPage.Master >

    <ContentPage BackgroundImage="overlay.png" Title="Hello" Icon="menu.png">
        <AbsoluteLayout>
            <StackLayout AbsoluteLayout.LayoutBounds="0.5,0.1,0.7,0.2" AbsoluteLayout.LayoutFlags="All">
                <Label Text="Nome do Medico" FontAttributes= "Bold" FontSize="20" TextColor="White"/>
                <Label Text="CRM 1234567890" FontSize= "15" TextColor="White"/>
            </StackLayout>
            <BoxView AbsoluteLayout.LayoutBounds="0,0.2,1,0.001" AbsoluteLayout.LayoutFlags="All" Color= "White"/>

             <StackLayout AbsoluteLayout.LayoutBounds="0.5,0.4,0.7,0.3" AbsoluteLayout.LayoutFlags="All">
                <Label Text="PERFIL" FontAttributes= "Bold" FontSize="20" TextColor="White"/>
                <Label Text="MEUS HORARIOS" FontSize= "20" TextColor="White"/>
            </StackLayout>
      <Button Image="power.png" AbsoluteLayout.LayoutBounds= "0.2,0.9,0.15,0.08" AbsoluteLayout.LayoutFlags="All" BackgroundColor= "Transparent" BorderRadius="20" />

        </AbsoluteLayout> 


    </ContentPage>
</MasterDetailPage.Master>

    <MasterDetailPage.Detail >
   <NavigationPage>
        <x:Arguments>
           <ui:DetailSixthScreen />
        </x:Arguments>
   </NavigationPage>
</MasterDetailPage.Detail>


`

Hi,
I have written a master detail page in xamarin forms. Master Page appears from left side in iOS and works good.I have set a background image in master content page and that is rendered in iOS But , this image is not rendered in Android although I have added image in resources of android project. I tried adding different images in resources (drawable_hdpi) but a blank white screen in displayed instead of backgroundimage.
Help Please

Viewing all 89864 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>