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

app crashing while implementing the qr code scanner

$
0
0

Can anyone please help me on this? While implementing the qr code scanner app is crashing. below process i followed i used Zxing plun for that after click on the image the camera opened and it s scanning and getting the result. after click on the image it will open the camera from there if i click on the back button app is crashing. i tried onbackbuttonpressed event. but no use.

Thanks in advance.


Forms Buttons and SKCanvas with TouchEffect?

$
0
0

I am currently using SkiaSharp along side a TouchEffect based on the fingerpainting sample and have come across an issue where button clicks are not always fired when a user actually taps a button, they do fire if you repeatedly press the button but it isnt reliable.

Has anyone else experienced this issue? Any known solutions?

Turn on location services without navigating to settings page?

Error on build app iOS, only on the production URL (https) :TrustFailure (One or more errors occu...

$
0
0

I have a problem when build my iOS project, only on the url production(for communication to web service). I think so wich the problem is the protocol HTTPS but i don't find any solution for this.My output:

P.S.: My HttpClient Implementation in iOS Build, is configured Managed(default)

System.Net.Http.HttpRequestException:

Thread finished: #10
The thread 0xa has exited with code 0 (0x0).
Thread finished: #11
The thread 0xb has exited with code 0 (0x0).
Thread finished: #6
The thread 0x6 has exited with code 0 (0x0).
2018-03-28 04:34:13.362 AppNivel.iOS[4830:44384]
Unhandled Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: TrustFailure (One or more errors occurred.) ---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: CertificateUnknown
at Mono.AppleTls.AppleTlsContext.EvaluateTrust () [0x000ca] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mono.AppleTls/AppleTlsContext.cs:269
at Mono.AppleTls.AppleTlsContext.RequirePeerTrust () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mono.AppleTls/AppleTlsContext.cs:210
at Mono.AppleTls.AppleTlsContext.ProcessHandshake () [0x00046] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mon
o.AppleTls/AppleTlsContext.cs:186
at ...

at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at AppNivel.iOS.Application.Main (System.String[] args) [0x00001] in D:\AppNivel_Bkp_14032018_1450h\AppNivel\AppNivel.iOS\Main.cs:17
2018-03-28 04:34:13.366 AppNivel.iOS[4830:44384] Unhandled managed exception:
An error occurred while sending the request (System.Net.Http.HttpRequestException)
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x0046c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:406
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/msco
rlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at ...

2018-03-28 04:34:13.401 AppNivel.iOS[4830:44384] critical:

Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

The app has been terminated.

Listview detect scroll state

$
0
0

How to detect scroll state in xamarin forms listview?
Similar approch in android with OnScrollStateChanged

Curved corners in tableview cells

$
0
0

Is it possible to have cells with curved corners displayed in a tableview? If so would anyone know how to go about it?

binding data to the background image property of a content page

$
0
0

i want to bind data dynamically to the background image property of a content page from my api.
can anyone suggest me how i can achieve that .... Thanks in advance

Transaction not found with paypal payments on Paypal.Forms

$
0
0

Here I am implementing Paypal.Forms. in xamarin forms
when a user proceed payments then it will show successfull transaction with Id,while checking on buyer paypal sandbox acount then it will nothing to show transactions.
var result = await CrossPayPalManager.Current.Buy(new PayPalItem("Test Product", new Decimal(10.00), "USD"), new Decimal(SaleAmonut));
if (result.Status == PayPalStatus.Cancelled)
{
await DisplayAlert("Message", "Payment Cancelled", "OK");
}
else if (result.Status == PayPalStatus.Error)
{
await DisplayAlert("Message", result.ErrorMessage, "OK");
}
else if (result.Status == PayPalStatus.Successful)
{
await DisplayAlert("Message", "Your Transaction id: "+result.ServerResponse.Response.Id, "OK");
}

and how to find "YOUR ID STRING" and MarchantName from paypal account?
CrossPayPalManager.Init(new PayPalConfiguration(PayPalEnvironment.NoNetwork, "YOUR ID STRING")
{
//If you want to accept credit cards
AcceptCreditCards = false,
//Your business name
MerchantName = "test facilitator",
//Your privacy policy Url
MerchantPrivacyPolicyUri = "https://www.example.com/privacy",
//Your user agreement Url
MerchantUserAgreementUri = "https://www.example.com/legal"
},this
);


Custom Template for last cell in a listView

$
0
0

Hello,
I need to have a custom template for the last view cell (and for some other cells). So I need to get the list count in my DataTemplateSelector.
I tried
<ListView x:Name="StatusList" ItemsSource="{Binding ListStatus}" SeparatorVisibility="None" HasUnevenRows="True"> <ListView.ItemTemplate> <interfaces:SuiviDataTemplateSelector x:Key="SuiviDataTemplateSelector" TemplateEmpty="{StaticResource TemplateEmpty}" TemplateMessage="{StaticResource TemplateMessage}" TemplateFinal="{StaticResource TemplateFinal}" ListViewLength="{Binding Source={x:Reference Name=StatusList},Path=BindingContext.ListStatus.Count}"/> </ListView.ItemTemplate> <ListView.RowHeight> <OnIdiom x:TypeArguments="x:Int32" Phone="100" Tablet="120"/> </ListView.RowHeight> </ListView>
but it dosen't work I get the "Position xx:yy. No property, bindable property, or event found for 'ListViewLength', or mismatching type between value and property. " error.

And my selector:
`class SuiviDataTemplateSelector : DataTemplateSelector
{
public DataTemplate TemplateMessage { get; set; }
public DataTemplate TemplateEmpty { get; set; }
public DataTemplate TemplateFinal { get; set; }
public int ListViewLength { get; set; }

    protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
    {
        var listView = container as ListView;
      //  var statusList = listView.Parent as 

        if (((StatutSuivi)item).Id >= ListViewLength)
            return TemplateFinal;
        else
        {
            if (((StatutSuivi)item).Done == false)

                return TemplateEmpty;
            else
                return TemplateMessage;
        }

    }
}`

Can anyone help?

Xamarin.Forms and Azure IoT Hub

$
0
0

Greetings!

I have several applications that need to send messages to Azure IoT Hub. One is UWP, and others are Xamarin.Forms apps (UWP and Android).

The UWP app works perfectly, I used Microsoft.Azure.Devices.Client in it to send messages. Also, the Xamarin.Forms UWP works as well. Problem is Android. Android app builds, but when I deploy it - it just shows a white screen.

I used Microsoft.Azure.Devices.Client NuGet package in all of them. Should I use a different NuGet package for Xamarin.Forms? Did I miss something?

I didn't try using Microsoft.Azure.Devices.Client.PCL. Should I try using it? Xamarin.Forms (UWP and Android) and UWP app are supposed to reference the same submodule, which contains code for sending messages to Azure IoT Hub.

Problems closing App

$
0
0

I have a Xamarin.Forms macOS app, and can't close it with the shortcut cmd+q. Nothing append.
Do I need to implement a menu for this, or not?

Can I include other xaml files from App.xaml?

$
0
0

I have a long list of styles in my App.xaml ResourceDictionary, I was wondering if i could split them into separate smaller xaml files and then include them from App.xaml.
If it's possible, can you point me to a tutorial, or show me a little code snippet?

Thanks!

Xamarin Forms Sockets

$
0
0

I don't get it, my friend and I are developing an API and our WebSocket services works, but not the mobile side.. I tried with a couple of clients, on the web, our echo messaging and everything works.

The thing is, I mean, the things seem like the socket is mono-directional. I tried the example of https://github.com/rdavisau/sockets-for-pcl#a-tcp-client:

var address = "127.0.0.1";
var port = 11000;
var r = new Random(); 

var client = new TcpSocketClient();
await client.ConnectAsync(address, port);

// we're connected!
for (int i = 0; i<5; i++)
{
    // write to the 'WriteStream' property of the socket client to send data
    var nextByte = (byte) r.Next(0,254);
    client.WriteStream.WriteByte(nextByte);
    await client.WriteStream.FlushAsync();

    // wait a little before sending the next bit of data
    await Task.Delay(TimeSpan.FromMilliseconds(500)); 
}

await client.DisconnectAsync();

First, after I get connected with this :

public async void ConnectSocketToAPIAsync()
    {
        SocketClient = new TcpSocketClient();
        await SocketClient.ConnectAsync("my.ws.service", 4242);
        ActiveSocketExchange();
    }

    public async void ActiveSocketExchange()
    {
        var bytesRead = -1;
        var buf = new byte[1];

        while (bytesRead != 0)
        {
            bytesRead = await SocketClient.ReadStream.ReadAsync(buf, 0, 1);
            if (bytesRead > 0)
                MessagingCenter.Send((App)Current, SOCKET_Message, System.Text.Encoding.UTF8.GetString(buf, 0, bytesRead));
        }
    }

Everything's fine, my TcpClient is well initialized (even the web-link becomes the http's API addr)

From my page view, when I'm done writing my text, I'm pressing the done button of the keyboard and this code is called:

private void InitSocketPart()
    {
        MessagingCenter.Subscribe<App, string>((App)Application.Current, App.SOCKET_Message, (sender, text) =>
        {
            SocketResponseText = text;
        });
    }

    private async void OnTextCompleted(object sender, EventArgs ea)
    {
        var bytes = Encoding.UTF8.GetBytes(TextToSend);
        try {
            if (App.SocketClient.WriteStream.CanRead)
                Debug.WriteLine("canRead");
            if (App.SocketClient.WriteStream.CanWrite)
                Debug.WriteLine("canWrite");

            App.SocketClient.WriteStream.Write(bytes, 0, TextToSend.Length);
            App.SocketClient.WriteStream.Flush();
        } catch (Exception e)
        {
            Debug.WriteLine(e);
        }
    }

So now CanWrite && CanRead are true, but nothing at all happens, even with the use of Async methods... Why so? I don't get it..

The use of messaging center is just to have only one point of incoming message. I'm using it for other things and it works perfectly :)

Thank for any help..

This bug isn't fixed

application terminates when ios is opened

$
0
0

My application runs on the emulator, on the mobile it opens and ends. Apple rejected it and gave me this error. You know what it is?

{"app_name":"meuappApp.IOS","timestamp":"2018-03-11 04:39:25.79 -0700","app_version":"1.0","slice_uuid":"edfcbb95-3b54-3d9f-9ad4-5cb6462aa990","adam_id":0,"build_version":"1.7","bundleID":"com.meuappapp.meuapp","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 11.2.5 (15D60)","incident_id":"3CD2E372-8BAC-4E7A-A03C-7D5E8B6768D2","name":"meuappApp.IOS"}

Incident Identifier: 3CD2E372-8BAC-4E7A-A03C-7D5E8B6768D2
CrashReporter Key: d1e255b6bbba63239d1ebcb358f272a4ff92d897
Hardware Model: iPad5,1
Device Model: J96AP
Process: meuappApp.IOS [337]
Path: /private/var/containers/Bundle/Application/5D8FA83E-3A75-4C62-B1AF-B0344CF22C33/meuappApp.IOS.app/meuappApp.IOS
Identifier: com.meuappapp.meuapp
Version: 1.7 (1.0)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd.development [1]
Coalition: com.meuappapp.meuapp [414]

Date/Time: 2018-03-11 04:39:25.6692 -0700
Launch Time: 2018-03-11 04:39:23.0013 -0700
OS Version: iPhone OS 11.2.5 (15D60)
Baseband Version: n/a
UDID: 19d5688bcf385b1407699196b9432bed7c64d9a9
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
abort() called

Filtered syslog:

Timestamp Thread Type Activity PID
2018-03-11 04:24:33.0712 -0700
0x46b 1024 0x0 100 hangtracerd: XPC: Client started new connection: pid 68
2018-03-11 04:24:33.0715 -0700
0x46b 1024 0x0 100 hangtracerd: New proc: /usr/libexec/backboardd(68)
2018-03-11 04:24:33.0716 -0700
0x46b 1024 0x0 100 hangtracerd: Initialization complete now watching hangs for backboardd(68) | com.apple.coreanimation.display.primary.hangEvent
2018-03-11 04:24:33.0748 -0700
0x400 1024 0x0 100 hangtracerd: refreshPreferences: Memory Logging Enabled
2018-03-11 04:24:33.0749 -0700
0x400 1024 0x0 100 hangtracerd: refreshPreferences: Hang Tracing Enabled
2018-03-11 04:24:33.0749 -0700
0x400 1024 0x0 100 hangtracerd: refreshPreferences: HangTracerEnableTailspin = 1
2018-03-11 04:24:33.0749 -0700
0x400 1024 0x0 100 hangtracerd: refreshPreferences: App Activation Logging Disabled
2018-03-11 04:24:45.6118 -0700
0x687 1024 0x0 100 hangtracerd: XPC: Client started new connection: pid 62
2018-03-11 04:24:45.6121 -0700
0x687 1024 0x0 100 hangtracerd: New proc: /System/Library/CoreServices/SpringBoard.app/SpringBoard(62)
2018-03-11 04:24:45.6122 -0700
0x687 1024 0x0 100 hangtracerd: Initialization complete now watching hangs for SpringBoard(62) | UIKit-runloop
2018-03-11 04:24:47.5319 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Hang detected 1.95s (UIKit-runloop)
2018-03-11 04:24:47.5468 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Attempting to save tailspin at /var/root/Library/Caches/hangtracerd/tmp/UIKit-runloop-SpringBoard-2018-03-11-042447.tailspin
2018-03-11 04:24:48.9447 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Moving tailspin to spool: /var/root/Library/Caches/hangtracerd/spool/UIKit-runloop-SpringBoard-2018-03-11-042447.tailspin
2018-03-11 04:24:48.9457 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard Log credits: 4 -> 3
2018-03-11 04:24:48.9457 -0700
0x687 1024 0x0 100 hangtracerd: Daily Log credits: 25 -> 24
2018-03-11 04:24:53.9378 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Hang detected 6.41s (UIKit-runloop)
2018-03-11 04:24:53.9381 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Attempting to save tailspin at /var/root/Library/Caches/hangtracerd/tmp/UIKit-runloop-SpringBoard-2018-03-11-042453.tailspin
2018-03-11 04:24:56.6531 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Moving tailspin to spool: /var/root/Library/Caches/hangtracerd/spool/UIKit-runloop-SpringBoard-2018-03-11-042453.tailspin
2018-03-11 04:24:56.6535 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard Log credits: 3 -> 2
2018-03-11 04:24:56.6535 -0700
0x687 1024 0x0 100 hangtracerd: Daily Log credits: 24 -> 23
2018-03-11 04:25:10.5716 -0700
0x935 1024 0x0 100 hangtracerd: refreshPreferences: Memory Logging Enabled
2018-03-11 04:25:10.5716 -0700
0x935 1024 0x0 100 hangtracerd: refreshPreferences: Hang Tracing Enabled
2018-03-11 04:25:10.5716 -0700
0x935 1024 0x0 100 hangtracerd: refreshPreferences: HangTracerEnableTailspin = 1
2018-03-11 04:25:10.5716 -0700
0x935 1024 0x0 100 hangtracerd: refreshPreferences: App Activation Logging Disabled
2018-03-11 04:36:33.0380 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Hang detected 1.25s (UIKit-runloop)
2018-03-11 04:36:33.0386 -0700
0x687 1024 0x0 100 hangtracerd: SpringBoard: Attempting to save tailspin at /var/root/Library/Caches/hangtracerd/tmp/UIKit-runloop-SpringBoard-2018-03-11-043633.tailspin


How to create custom render for sfchedule calendar in xamarin forms

$
0
0


i want to convert small green dot in to big green dot like this blow


here we use sfschedule package for creating calendar , can any one tell me how to get this please tell me any one

Multiple colors in Bindable Label

$
0
0

I have a label which has its binding through a view model. Out of label's text few characters need to be in a different color. I thought of using formatted text and using different spans, but unfortunately we can't bind spans with view model. Can someone help me what to do? (my text is like " Lorem epsum ...more". The requirement is to have a different color for "...more".

How to implement an Android Service in Xamarin.Forms

$
0
0

Hi! I have an application and I want to periodically check from a web service if an item has been added to a table on a database, the new item should be added to the listview the user sees.
I'm using PCL and I did accomplish it creating a new Task and then with a timer checking every specific time but I want it to work if the app is closed too, the user should get a notification that a new item has been added.
So I was doing some research and I came across android services, the info said that the service will continue, regardless of the app state, until you tell it to stop. But I haven't found many examples and I don't know how to implement the code that I already had to the service.

This is the code that I had
Task.Run(() =>
{
Device.StartTimer(TimeSpan.FromSeconds(secs), checkUpdates);
});

bool checkUpdates()
          {
            if (isOnline)
            {
                var lastUp= Application.Current.Properties["lastUpdate"] as string;

    //the method returns a true if an item has been added
                if (service.NewItem(DateTime.Parse(lastUp)))
                {
                    var it = service.getNewItem(DateTime.Parse(lastUp));

                    Device.BeginInvokeOnMainThread(() =>
                    {    
                            notification.ShowNotification(it.Title, 1000);
                            listView.Insert(0, it);
                     }                            
                    });                  
                }
                App.Current.Properties["lastUpdate"] = DateTime.Now.ToString();
            }
            return true;
        }

This is the code that works when the app is open, and I'm trying to use dependecy services to consume the service in my PCL. Here's what I've got so far:

     public interface IService
        {
            void Start();
        }

      [Service]
        public class DependentService : Service, IService
        {
            public void Start()
            {
                var intent = new Intent(Android.App.Application.Context, typeof(DependentService));
                Android.App.Application.Context.StartService(intent);
            }

            public override IBinder OnBind(Intent intent)
            {
                return null;
            }

            public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
            {
                // From shared code or in your PCL


                return StartCommandResult.NotSticky;
            }
        }

The problem is that I don't know how to implement the same code that I had in the timer here. Can someone please help?

Xamarin Forms Sockets

$
0
0

I don't get it, my friend and I are developing an API and our WebSocket services works, but not the mobile side.. I tried with a couple of clients, on the web, our echo messaging and everything works.

The thing is, I mean, the things seem like the socket is mono-directional. I tried the example of https://github.com/rdavisau/sockets-for-pcl#a-tcp-client:

var address = "127.0.0.1";
var port = 11000;
var r = new Random(); 

var client = new TcpSocketClient();
await client.ConnectAsync(address, port);

// we're connected!
for (int i = 0; i<5; i++)
{
    // write to the 'WriteStream' property of the socket client to send data
    var nextByte = (byte) r.Next(0,254);
    client.WriteStream.WriteByte(nextByte);
    await client.WriteStream.FlushAsync();

    // wait a little before sending the next bit of data
    await Task.Delay(TimeSpan.FromMilliseconds(500)); 
}

await client.DisconnectAsync();

First, after I get connected with this :

public async void ConnectSocketToAPIAsync()
    {
        SocketClient = new TcpSocketClient();
        await SocketClient.ConnectAsync("my.ws.service", 4242);
        ActiveSocketExchange();
    }

    public async void ActiveSocketExchange()
    {
        var bytesRead = -1;
        var buf = new byte[1];

        while (bytesRead != 0)
        {
            bytesRead = await SocketClient.ReadStream.ReadAsync(buf, 0, 1);
            if (bytesRead > 0)
                MessagingCenter.Send((App)Current, SOCKET_Message, System.Text.Encoding.UTF8.GetString(buf, 0, bytesRead));
        }
    }

Everything's fine, my TcpClient is well initialized (even the web-link becomes the http's API addr)

From my page view, when I'm done writing my text, I'm pressing the done button of the keyboard and this code is called:

private void InitSocketPart()
    {
        MessagingCenter.Subscribe<App, string>((App)Application.Current, App.SOCKET_Message, (sender, text) =>
        {
            SocketResponseText = text;
        });
    }

    private async void OnTextCompleted(object sender, EventArgs ea)
    {
        var bytes = Encoding.UTF8.GetBytes(TextToSend);
        try {
            if (App.SocketClient.WriteStream.CanRead)
                Debug.WriteLine("canRead");
            if (App.SocketClient.WriteStream.CanWrite)
                Debug.WriteLine("canWrite");

            App.SocketClient.WriteStream.Write(bytes, 0, TextToSend.Length);
            App.SocketClient.WriteStream.Flush();
        } catch (Exception e)
        {
            Debug.WriteLine(e);
        }
    }

So now CanWrite && CanRead are true, but nothing at all happens, even with the use of Async methods... Why so? I don't get it..

The use of messaging center is just to have only one point of incoming message. I'm using it for other things and it works perfectly :)

Thank for any help..

This bug isn't fixed

Viewing all 58056 articles
Browse latest View live


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