我在Xamarin.Forms应用程序中使用ZXing.Net.Mobile ZXingScannerView。目前我的目标是Android API 21+和Windows Mobile 10.我通过IsScanning属性启用/禁用扫描程序。虽然它适用于仿真器和真实设备上的UWP应用,但对于Android来说却不是这样。
在Android模拟器和真实设备上,设置IsScanning = true
不会重新启用相机流。
我正在使用与此示例类似的代码:
SomePage.xaml
<ContentPage.Content>
...
<StackLayout>
<zxing:ZXingScannerView
x:Name="zxing"
Result="{Binding ScannerResult, Mode=TwoWay}"
IsScanning="{Binding ScannerScanning}"
ScanResultCommand="{Binding ScannedCommand}"/>
<Button Text="ON" Command="{Binding ScannerOnCommand}" />
<Button Text="OFF" Command="{Binding ScannerOffCommand}" />
...
</StackLayout>
</ContentPage.Content>
SomeViewModel.cs
public class SomeViewModel
{
....
public bool ScannerScanning { get; set; }
public Result ScannerResult { get; set; }
public ICommand ScannedCommand => new Command(() => ExecuteScannedCommand());
public ICommand ScannerOnCommand => new Command(() => ExecuteScannerOnCommand());
public ICommand ScannerOffCommand => new Command(() => ExecuteScannerOffCommand());
private async Task ExecuteScannedCommand()
{
Debug.WriteLine();
}
private void ExecuteScannerOnCommand()
{
ScannerScanning = true;
}
private void ExecuteScannerOffCommand()
{
ScannerScanning = false;
}
...
}
我想念什么,或者是ZXing.Net.Mobile中的错误?