XZing with xamarin forms

0

Hello I'm trying to implement barcode reading in my Xamarin.Forms app according to the documentation.

link , but when I try to run the code below

private async void ExecuteBuscaInventarioCommand()
{
    try
    {
        var scanner = new ZXing.Mobile.MobileBarcodeScanner();
        var result = await scanner.Scan();

        if (result != null)
            Codigo = result.Text;
    }
    catch (Exception ex)
    {
        await App.Current.MainPage.DisplayAlert("Ops!", ex.Message, "Ok");
    }
}

I get the message System.NotSupportedException: Use the platform specific implementation instead!

In the documentation says for me to add an android support component but the link that is broken ...

In the constructor I put this

MobileBarcodeScanner.Initialize(Application);

but Initialize is not recognized.

Can someone give me a light?

    
asked by anonymous 01.03.2017 / 17:04

1 answer

0

In the android project did you add this snippet to activity?

ZXing.Net.Mobile.Forms.Android.Platform.Init();

And did you override the OnRequestPermissionsResult method?

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{ 
global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult (requestCode, permissions, grantResults);
}

Take a look at the github project and see if it helps.

    
02.03.2017 / 14:54