Erik
Erik

Reputation: 157

ZXing.Net.Mobile scan doesn't trigger

I'm currently trying to implement this compontent into my android application built with Xamarins mono for andriod.

I'm having this issue that I can't get any result returned back from the scanner.Scan(); method, the scanner starts and nothing happens?!

So I've tried downloading the sample projects from github and when I try scanning barcodes using the sample code provided there it's the same problem. It will not fire. Here is some of the code responsible for starting the scanner and handeling the result:

public async void ScanArticleNumber()
        {
            //Tell our scanner to use the default overlay
            scanner.UseCustomOverlay = false;

            //We can customize the top and bottom text of the default overlay
            scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away";
            scanner.BottomText = "Wait for the barcode to automatically scan!";

            //Start scanning
            var result = await scanner.Scan();

            HandleScanResult(result);
        }

void HandleScanResult(ZXing.Result result)
        {
            string msg = "";

            if (result != null && !string.IsNullOrEmpty(result.Text))
                msg = "Found Barcode: " + result.Text;
            else
                msg = "Scanning Canceled!";

            Activity.RunOnUiThread(() =>
            {
                Toast.MakeText(Activity.BaseContext, msg, ToastLength.Short).Show();
            });
        }

The code never reaches the HandleScanResult method even tho I'm shooting loads of barcodes with the camera.

Any ideas why?

Upvotes: 1

Views: 3454

Answers (1)

Erik
Erik

Reputation: 157

Problem was solved by downloadning the latest version of ZXing.Net.Mobile from Github and then running that sample project and taking the following dlls from the bin folder:

  • ZXing.Net.Mobile.dll
  • zxing.monoandroid.dll
  • Xamarin.Android.Support.v4.dll

I replaced my current ddls with these and it worked! This is probably because I from first downloaded the dlls from xamarin components, the files was probably not up to date.

Hope this helps.

Upvotes: 1

Related Questions