1

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?

Erik
  • 117
  • 3
  • 15
  • Dumb question, perhaps, but are you debugging this through an emulator or via a connected mobile device? Does the scan complete (but never hit `HandleScanResult`) - meaning, does the scanner UI close and return you to the application? – Tieson T. Apr 11 '14 at 23:46
  • I'm debugging in a mobile device. And nothing happends, meaning I'm not returned to the application until I close the scanner. – Erik Apr 12 '14 at 12:29
  • If I read that right, it sounds like the scanner never captures the barcode. Just to eliminate the obvious, have you added the camera permission to your app? – Tieson T. Apr 14 '14 at 03:56
  • These permissions I've added – Erik Apr 14 '14 at 13:28

1 Answers1

1

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.

Erik
  • 117
  • 3
  • 15