Scandit条形码扫描仪在扫描时显示空白相机

时间:2017-07-18 11:38:26

标签: xamarin barcode-scanner

我正在尝试在我的应用程序中实现scandit条形码扫描器。我下载了它的示例演示,它的工作正常。

我试图在我的应用程序中实现相同的代码。但它在扫描时显示黑屏。 我也给了相机访问权限。找不到任何东西。

如果有人也面临同样的问题,请帮忙。任何建议最受赞赏。 提前谢谢

这是我的代码

    using FormBot.ViewModels.Abstract;
using Scandit.BarcodePicker.Unified;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;

namespace FormBot.ViewModels
{
 public class SerialNumberViewModel: BaseViewModelDemo
{
    private string _recognizedCode;

    public ICommand StartScanningCommand => new Command(async () => await StartScanning());

    public string RecognizedCode
    {
        get
        {
            return (_recognizedCode == null) ? "" : "Code scanned: " + _recognizedCode;
        }

        set
        {
            _recognizedCode = value;
        }
    }

    public SerialNumberViewModel()
    {

        ScanditService.ScanditLicense.AppKey = "Key";
        ScanditService.BarcodePicker.DidScan += BarcodePickerOnDidScan;
    }

    private async void BarcodePickerOnDidScan(ScanSession session)
    {
        RecognizedCode = session.NewlyRecognizedCodes.LastOrDefault()?.Data;
        await ScanditService.BarcodePicker.StopScanningAsync();
    }

    private async Task StartScanning()
    {
        await ScanditService.BarcodePicker.StartScanningAsync(false);
    }
}

}

在app.xaml.cs

 private static string appKey = "key";
 ScanditService.ScanditLicense.AppKey = appKey;

1 个答案:

答案 0 :(得分:1)

在Androidmanifest.xaml文件中设置android-hardwareaccelerated = true为我工作。

相关问题