Xzing with Xamarin Forms

Asked

Viewed 358 times

0

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

https://components.xamarin.com/gettingstarted/zxing.net.mobile , but when I try to execute 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");
    }
}

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

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

In the builder I put this

MobileBarcodeScanner.Initialize(Application);

but Initialize is not recognized.

Someone can give me a light?

  • http://stackoverflow.com/a/39354186/6809703

1 answer

0


In the android project you added this excerpt in Activity ?

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

And 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 project on github and see if it helps you.

  • Thanks In fact Zxing.Net.Mobile.Forms.Android.Platform.Init() This 100% now

Browser other questions tagged

You are not signed in. Login or sign up in order to post.