Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 701 forks source link

ZXing is not scanning on Android (Xamarin app) #646

Open jrahma opened 6 years ago

jrahma commented 6 years ago

Hi,

I am using below code to scan a QR code. I am able to view the camera streaming but it is not scanning any QR code.

How can I fix this please?

public void Scan() { try { scanner.Options = new MobileBarcodeScanningOptions() { UseFrontCameraIfAvailable = false, //update later to come from settings PossibleFormats = new List(), TryHarder = true, AutoRotate = false, TryInverted = true, DelayBetweenContinuousScans = 2000, };

    scanner.VerticalOptions = LayoutOptions.FillAndExpand;
    scanner.HorizontalOptions = LayoutOptions.FillAndExpand;

    // scanner.IsVisible = false;

    scanner.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);
    // scanner.Options.PossibleFormats.Add(BarcodeFormat.DATA_MATRIX);
    // scanner.Options.PossibleFormats.Add(BarcodeFormat.EAN_13);

    scanner.OnScanResult += (result) => {
        // Stop scanning
        scanner.IsAnalyzing = false;
        scanner.IsScanning = false;

        if (scanner.IsScanning)
        {
            scanner.AutoFocus();
        }

        // Pop the page and show the result
        Device.BeginInvokeOnMainThread(async () => {
            if (result != null)
            {
                await DisplayAlert("Scan Value", result.Text, "OK");
            }
        });
    };

    mainGrid.Children.Add(scanner, 0, 1);
}
catch (Exception ex)
{
    DisplayAlert("Scan Value", ex.ToString(), "Error");
}

}

Charly01 commented 6 years ago

Seems like I have pretty much the same issue: I did try out the FormsSample, but on my android-device there is no continuous update of the camera (no video) - there is just ONE picture (like a photo) and no scanning.

skir commented 6 years ago

In my app QR scanning works fine with 2.2.9 version, but not works at all with update to 2.3.2.

victorarce commented 5 years ago

It wasn't working for me, until I only selected CODE-128 as the only format. Android is way slower as you already know

lbushby commented 4 years ago

In my app QR scanning works fine with 2.2.9 version, but not works at all with update to 2.3.2.

Just encountered the same problem in 2.4.1 when trying to use ZXing with Xamarin on Android for the first time and rolling back to 2.2.9 seems to have fixed it