Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Xamarin support for cognitive speech service

$
0
0

I want to use the Cognitive speech service (real-time continuous speech to text and interim results) in the Xamarin app. Is there any SDKs or plugin available? Since REST API has some limitations (no interim results), i am unable to go with it.


Xamarin Forms execution returns from await Httpclient PostAsync

$
0
0

I am calling a methodgetaddress(); inside viewmodel for getting address information from API. But while debugging, execution returns at var response = await client.PostAsync(base_url + "api_delivery_details", formcontent).ConfigureAwait(false);to the calling method getaddress() but executes the remaining portion later.so getting null result. How to execute all from first time?

public async void Get_branch_products()
    {
        RestClient restClient = new RestClient();            
        getaddresses();  //this is the calling method

        long delivery_fee1 = long.Parse(delivery_fee);
        GrandTotal = Total + (Total * Tax) / 100 + delivery_fee1 ;            
        OnPropertyChanged("GrandTotal");
        tax_amt = (Total * Tax) / 100;
        OnPropertyChanged("tax_amt");
    }

public async void getaddresses()
    {
        ind_vis = true;
        OnPropertyChanged("ind_vis");             
        int user_id = (int)App.Current.Properties["user_id"];
        RestClient restClient = new RestClient();
        var result = await restClient.Get_address(user_id);  //calling restAPI method

        if (result.status == "success")
        {
            ind_vis = false;
            OnPropertyChanged("ind_vis");

public async Task<Address> Get_address(int user_id)
    {
        var formcontent = new FormUrlEncodedContent(new[]
        {
           new KeyValuePair<string,string>("user_id",user_id.ToString())
        });
  //returns from here// var response = await client.PostAsync(base_url + "api_delivery_details", formcontent).ConfigureAwait(false); 
  //executes later// var result = await response.Content.ReadAsStringAsync();
        var Items = JsonConvert.DeserializeObject<Address>(result);
        return Items;
    }

Xamarin Essentials Geolocator - accuracy and response

$
0
0

Has anyone any experience with geolocator - I am beginning to experiment trying to build a simple gps logger.
I seem to get some weird results - at first the code returns a credible location then it just seems to record the same position for 10 mins at a time (despite moving at >20mph
the routine is embedded within a timer which fires every 12 seconds - the timeout on the getposition async call is 6 seconds
Some things I dont quite understand - it seems that in the event of a timeout GetLocationAsync simply returns the last position - it seems so because the time stamp is the same
I just dont get why it is not firing a position update - I tried using a 2 seconds timeout and it did better than 6 second - I've also increased the timer firing to 15 seconds and the timeout on the Geolocator to 10 seconds but doesn't seem to stop the position update from 'freezing' for up to 10 mins
Yes I am aware of the need to have a clear view of the sky
The odd thing is I have an Android app utility GPS status which shows satellites and a fix - once its locked on it updates about every 0.8 seconds - why cant geolocator do that? Is there any inherent reason why the response from the underlying location service should be slower with Xamarin Essentials?
Also I have resurrected an older Xamarin Android sample app which uses the Android location service directly (not Forms) and this seems to update happily and frequently. Is it something to do with Forms?
Anyone know if I could use dependency service and call the Android location services directly ? Or would that be a daft idea? I'd really like to stick with Forms and Essentials - James has always been in the vanguard of making complex things accessible to beginners like me.
I'd welcome any comments on the above conjectures and also - is my code approach the best way of doing it ?

I write all the positions to a gpx file so I can plot them on a map and frankly the results are gobbledegook

code snippet
{
static string gpx ="";

async void OnTimedEventAsync(Object source, System.Timers.ElapsedEventArgs e)
        {
                 request = new GeolocationRequest(GeolocationAccuracy.High,TimeSpan.FromSeconds(6));
                   var x = await Geolocation.GetLocationAsync(request);
                    var acc = x.Accuracy;
                    var dt = x.Timestamp;
                    dt = dt.UtcDateTime;
                    var alt = x.Altitude;                        
                    alt = Math.Round((float)alt * 3.28084, 0); // convert to feet
                    var spd = x.Speed;
                     spd = Math.Round((float)spd * 1.94384, 0); //convert to knots
                    var cse = x.Course;
                    var dt2 = dt.ToString("yyyy-MM-ddTHH:mm:ssZ");

                    gpx = gpx + "<trkpt lat =\"" + x.Latitude.ToString() + "\" lon=\"" + x.Longitude.ToString() + "\">";
                    gpx = gpx + "<time>" + dt2 + "</time>";
                    gpx = gpx + "<course>" + cse.ToString() + "</course>";
                    gpx = gpx + "<speed>" + spd.ToString() + "</speed>";
                    gpx = gpx + "<acc>" + acc.ToString() + "</acc>";
                    gpx = gpx + "</trkpt>";
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        // interact with UI elements to show something happening
                        lab1.Text = gpx;
                    });                    
        }

}

Possible bug in Visual Studio for Mac 7.7.4

$
0
0

Hi All,

I am new to Xamarin, but I have 18 years development experience in .Net.

I upgraded to VS2017 Community Edition for mac to version 7.7.4 today.

I then started getting the following event error code. The attached error code was generated when I tried to enter values into Single Line enty in the FormsGallery project using the iOS simulator.

I am getting the same error in my main App project, interestingly the App has not crashed, so I am trying to determine whether the issue is in the application, the sumulator, or the Application output log.

I hope someone can help.

Regards

Ross

Extract from Application Output:

2019-02-03 21:29:40.111993+1100 FormsGallery.iOS[3573:99148] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=3573
2019-02-03 21:29:40.112705+1100 FormsGallery.iOS[3573:99148] SecTaskCopyDebugDescription: FormsGallery.iOS[3573]/0#-1 LF=0
2019-02-03 21:29:40.127757+1100 FormsGallery.iOS[3573:99148] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2019-02-03 21:30:09.988279+1100 FormsGallery.iOS[3573:99148] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=3573
2019-02-03 21:30:09.988497+1100 FormsGallery.iOS[3573:99148] SecTaskCopyDebugDescription: FormsGallery.iOS[3573]/0#-1 LF=0
2019-02-03 21:30:21.217978+1100 FormsGallery.iOS[3573:99148] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"",
"",
"",
"",
"",
""
)

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-02-03 21:30:21.219537+1100 FormsGallery.iOS[3573:99148] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"",
"",
"",
"",
"",
""
)

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

How to change TabbedPage bar height in Android? (Already overriding TabbedRenderer)

$
0
0

So I've created and successfully replaced the TabbedPage renderer with a custom one. However, I have no clue where it calculates the height, can anyone point me to the right method?

Adding microsoft.net.http to an application

$
0
0

Hi,

I'm currently part way through porting an iOS app over to macOS. Pretty much everything is done, but when I come to testing I'm getting this error

Method not found: void System.Net.Http.HttpClientHandler.set_AutomaticDecompression(System.Net.DecompressionMethods)

I'm using FubarRestSharp in my mvvm project which from memory uses Microsoft.Net.Http for the decompression. The answer to get rid of this error is to add the Microsoft.Net.Http package from nuget but the problem is that the version on nuget (2.2.29) isn't happy with macOS. I've tried adding a handler in the code calling the web service, but that's not cutting it either.

I've tried just adding a reference back to the packages, but that's not working either.

Any ideas?

Firebase.Firestore.FieldValue does not contain a definition for ArrayUnion

$
0
0

Hello!

I'm currently working on an application in iOS and Android that uses Firebase. I'm trying to add a value to an existing array in firestore. In iOS I had no problems using 'FieldValue.FromArrayUnion(obj)'. However in Android I'm having a hard time since this method does not exist. Any ideas of how can I add a value into my array without overwriting its data?

Thank you.

Music Isn't playing on IOS

$
0
0

I used this guide: www.youtube.com/watch?v=9h7523oj7nA&feature=youtu.be to learn how to add music to an IOS app on Xamarin. When I run it using the simulator everything works fine and I can hear the music. When I run it on my phone I hear nothing.


get device language/culture..

$
0
0

hello,
xamarin forms 2.4.0.282

i cant get the device language when iis set on Hebrew!
i do get it on other lang, but in Hebrew in get 'iv' or invariant language

var r = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

thankx

Xamarin forms android - disables SSL CA validation

$
0
0

Hello we are facing a security problem with apk, there's a application validating our apk (Appthority) and reports this:

Disables SSL CA Validation

[
{
"status": "DISABLED",
"hostname": "xxx.xxxxxx-xx.com",
"connection": "10.27.68.128:40326->192.129.240.16:443",
"validation_hostnames": [
]

wa are using https connection for WS and SSL/TLS implementation, and trusted certificate

this only happens with apk but not with ipa

greetings

How do I do proper regional formatting in iOS? (Xamarin.Forms)

$
0
0

I have read about a million posts on the topic and all the approaches I have seen thus far appear to be incomplete.

Configuration 1
Language = Español (España), Region = España.
Using this configuration I create a new CultureInfo("es-ES") and assign it to DefaultThreadCurrentCulture and DefaultThreadCurrentUICulture, everything works as expected. My numbers are formatted correctly I.e. 234,55, the numeric keyboard pops up using the "," as decimal separator. Life is good.

Configuration 2
Language = Español (España), Region = Canada.
Using this configuration I create a new CultureInfo("es-CA") which of course fails. I then fallback to new CultureInfo("es") and assign it to DefaultThreadCurrentCulture and DefaultThreadCurrentUICulture. Under this configuration my numbers are formatted using "," which I expect but the numeric keyboard utilizes "." as the decimal separator.

Is it possible to have the keyboard respect the threads culture settings? How does iOS decide that the decimal separator should be "." when Canada supports point and comma?

Add Multiple Pins to Map in MVVM pattern

$
0
0

Hello,

I am having issues trying to understand how to add Pins to a map in MVVM pattern. (I can have multiple maps in the view).

Here's my ViewModel Code.

<flv:FlowListView SeparatorVisibility="Default" HasUnevenRows="True" FlowItemTappedCommand="{Binding ItemTappedCommand}" FlowLastTappedItem="{Binding LastTappedItem}" FlowColumnMinWidth="600" FlowItemsSource="{Binding DashboardWidgets}" >
    <flv:FlowListView.FlowColumnTemplate>
                <StackLayout BackgroundColor="White" Margin="1">
                    <!--Map Widgets -->
                    <StackLayout BackgroundColor="{Binding bgcolor}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" IsVisible="False" >
                        <StackLayout.Triggers>
                            <DataTrigger TargetType="StackLayout" Binding="{Binding resultsettype}" Value="map">
                                <Setter Property="IsVisible" Value="True"/>
                            </DataTrigger>
                        </StackLayout.Triggers>
                        <StackLayout Orientation="Vertical"  Padding="4" HeightRequest="400" WidthRequest="600">
                            <maps:Map x:Name="MyMap" IsShowingUser="true" MapType="Hybrid" />
                        </StackLayout>
                    </StackLayout>
                    <!--Image Widgets -->
                    <StackLayout BackgroundColor="{Binding bgcolor}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" HeightRequest="200" WidthRequest="600" Padding="4" IsVisible="False">
                        <StackLayout.Triggers>
                            <DataTrigger TargetType="StackLayout" Binding="{Binding resultsettype}" Value="image">
                                <Setter Property="IsVisible" Value="True"/>
                            </DataTrigger>
                        </StackLayout.Triggers>
                        <StackLayout Padding="1" HeightRequest="200" WidthRequest="600">
                            <Image Source="{Binding contentvalue, Converter={StaticResource LocalBase64ToImageConverter}}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
                        </StackLayout>
                    </StackLayout>
    </flv:FlowListView.FlowColumnTemplate>

I have an Observable collection of DashboardWidgets which can hold a map, image, integer or a list.
If it's a map, I will get all the pins in VM and somehow bind them to the map. Since I am using mvvm pattern, I shouldnot access the Map in my VM and moreover I have no clue how to do it either.

So I far have tried Extending the Map to make pins bindable but to no success.

    public class ExtendedMap : Map
        {
        public static readonly BindableProperty PinsProperty = BindableProperty.Create(nameof(MultiPins), typeof(IList<Pin>), typeof(ExtendedMap), new List<Pin>());
        public List<Pin> MultiPins
            {
            get {
                                var val = (List<Pin>)GetValue(PinsProperty);
                                return new List<Pin>();
                                }
                        set => SetValue(PinsProperty, value);
                        }                
                    }      

I tried creating a contentview binding it's content to property inside vm but no luck.

XAML:
Tried both. None worked.

<contentview content={binding widgetResult } />
<contentview content={binding mapresult} />

VM:
VM implements IPropertyChanged.

var map = new Map(MapSpan.FromCenterAndRadius(new Position(37, -122), Distance.FromMiles(0.3)))
                {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
                };
        (await GetMapPins(widget.filter)).ForEach(f => map.Pins.Add(f));
        widget.widgetResult = new ContentView
                {
                    Content = map
                 };
        widget.mapresult = map;

focus on xamarin

$
0
0

I have a reasonable knowledge of building applications with javascript and apache cordova.
Would it be compensatory for me to learn the xamarim? I believe that I would have to devote valuable time to the learning curve, not knowing whether I would gain this time with new visual studio features for xamarin.

Xamarin Forms Application.Current Properties Backup on user Google Drive account

$
0
0

I want to store my Application.Current.Properties to user's Google Drive Account as backup via Google Drive REST API v3. And Sync functionality from App to Drive and vice a versa.

I have searched and found very little info about it. But unable to take start as I am a newbie in using the user's Cloud storage.

So can anyone guide me how to achieve this? No such documentation or video tutorial found to do it from scratch. I need help.
Thanks in advance.

Is possible to create a Button containing both a Text and and an icon fonts as Image?

$
0
0

Hello,

I tried to create a button that looks like this:

But, I would like to use a icon fonts (like FontAwesome) instead of a Bitmap as source of the Image.

I thought that I could it with Iconize, but it's not the case: IconizeButton only replace the Text by the FontIcon.

So is there a way to manage both label in Text and FontIcon in Image for a Button?


Error on launching

$
0
0

Hi there! When i trying to launch empty blank template cross-platform xamarin.forms app on phone, visual studio throw this error:
resource directory '~\Test\Test\Test.Android\obj\Debug\81\lp\20\jl\res' does not exist Test.Android
output:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1703,2): error APT0000: resource directory '~\Test\Test\Test.Android\obj\Debug\81\lp\20\jl\res' does not exist

Tell me please way to fix it.
Thanks

Reproduce carousel view behaviour/animation/transition to a horizontal scroll view.

$
0
0

Hey developers,
I have so far tried to use a carousel view due to its ease of use and of course its performance. But I tried to show the tail of each UI elements (let's say we've a bunch of cards) whatever the position is as shown in the picture. I've googled a lot and posted another question in this forum but since then I changed the project UI a little bit so I ignored the given solution and now I am on my own again, I resolved it (show the next card's tail or/and the previous), I'll write down the structure I used in XAML but first let me highlight my requirements.
I want to reproduce the behaviour, animation/transition on swiping of the carousel view to my view, because I am actually using a horizontal scroll view with a Flex layout inside.
Here is the structure :

Now I've tried two options :
1- Use of Scrolled event in the scroll view but that hasn't been a great option because it fire the events (animation or transition) after the scroll is done, in my case it should fire the event since scrolling started.
2- Use of SwipeGestureRecognizer on Scrollview, FlexLayout and BoxView : couldn't get a stable behaviour on the 2 first attempts but when I used a BoxView I couldn't get each StackLayout (the StackLayout is my card) inside the BoxView (It wasn't built for that).

Here is my UI after I used a horizontal scroll view :

here is the behaviour I wanted to reproduce to my view :
https://media.giphy.com/media/l0NwH3XDSYhQ6l4TC/giphy.gif

ListView with CachingStrategy="RecycleElement" UIKit Consistency error

$
0
0

Using Visual Studio 2019 Preview, I created an Xamarin Forms Shell project with iOS and Android apps.

I updated the MockDataStore to add 1000 items to the list.

The list view has CachingStrategy="RecycleElement"

        <ListView 
            x:Name="ItemsListView" 
            ItemsSource="{Binding Items}"
            VerticalOptions="FillAndExpand"
            HasUnevenRows="true"
            IsPullToRefreshEnabled="false"
            CachingStrategy="RecycleElement"
            ItemSelected="OnItemSelected">

When I run the app in the iOS simulator or on an iPhone, I can scroll the list, but eventually the app crashes with the error below.

If I change the CachingStrategy="RecycleElementAndDataTemplate", the error no longer occurs.

Any idea why? What is it doing under the covers that I need to account for?

Thank you,

Michael

Unhandled Exception:
UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
at UIKit.UIApplication.EnsureUIThread () [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:88
at UIKit.UIGestureRecognizer.RemoveTarget (Foundation.NSObject target, System.IntPtr action) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:342
at UIKit.UIGestureRecognizer.OnDispose () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:41
at UIKit.UIGestureRecognizer.Dispose (System.Boolean disposing) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:959
at Foundation.NSObject.Finalize () [0x00000] in /Library/Fr
ameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:143
2019-02-04 11:41:49.073822-0500 WhiskyPassport.iOS[19858:1375488] Unhandled managed exception:
UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. (UIKit.UIKitThreadAccessException)
at UIKit.UIApplication.EnsureUIThread () [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:88
at UIKit.UIGestureRecognizer.RemoveTarget (Foundation.NSObject target, System.IntPtr action) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.g.cs:342
at UIKit.UIGestureRecognizer.OnDispose () [0x00016] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/UIKit/UIGestureRecognizer.cs:41
at UIKit.UIGestureRecognizer.Dispose (System.Boolean disposing) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin
.iOS/UIKit/UIGestureRecognizer.g.cs:959
at Foundation.NSObject.Finalize () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.6.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:143

Android Emulator Windows Hypervisor performance

$
0
0

I recently removed HAXM and enabled Hyper-v and Hypervisor for running the android emulator. Followed the docs and configured everything. Everything
seems to work fine, however the performance is a bit laggy. Not unusable and not terrible but not as snappy as Intel HAXM. So went back to using HAXM.

During research I noted that the official android docs recommend HAXM over Hypervisor.

Anyone else have a similar experience? Just curious.

Cheers

App crashing when listview scrolling

$
0
0

Recently I just implemented a listview with a custom cell and a custom selector in Xamarin.Forms, my custom cell have two text binding properties and the selector just pick the correct custom cell based on a condition, I fill the listview with several amount of data (+100), it looks like it works correctly, but when I scroll down/up the screen, the app just crashes. I have tried to use CachingStrategy with RecycleElement and RetainElement but the problem remains. Does anyone have the same issue? I'm stuck.

Viewing all 204402 articles
Browse latest View live


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