Qr代码扫描后相机崩溃了Windows手机

时间:2016-10-06 13:23:14

标签: c# windows-phone-8.1 zxing windows-10-universal windows-10-mobile

我有qr阅读器的应用程序。它是为WindowsPhone 8.1(winRT)开发的,后来升级到通用Windows Phone。在WP 8.1上,它正常工作。问题出在windows 10 mobile上。场景:用户导航到扫描仪页面,它扫描,解码qr(使用Zxing解码),向服务器发送信息,并在成功扫描后返回上一个视图。有时,当用户再次导航到扫描仪视图时,预览为全灰色,并抛出异常:找不到与此错误代码关联的文本-System.Exception。它发生在这种方法上:

  private async void InitializeQrCode()
    {
        if (_mediaCapture == null)
        {
            _mediaCapture = new MediaCapture();
            var deviceInformation = await GetCameraDeviceInfoAsync(Windows.Devices.Enumeration.Panel.Back);
            var settings = InitCaptureSettings(deviceInformation);


            try
            {
                await _mediaCapture.InitializeAsync(settings);
            }
            catch (Exception ex)
            {
                StopAndDisposeCamera();
                scanButton.IsEnabled = false;
                MessageDialog msgbox = new MessageDialog("error");
                await msgbox.ShowAsync();
                Xamarin.Insights.Report(ex);
            }

            if (_mediaCapture != null)
            {
                _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
                _mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees);
                var torch = _mediaCapture.VideoDeviceController.TorchControl;
                if (torch.Supported) torch.Enabled = true;
                SetFocus();
            }
        }

完全在:

 await _mediaCapture.InitializeAsync(settings); 

此相机不工作后。当我启动默认相机应用程序时,它会显示黑屏信息,我应该重启设备和错误代码:0xe80110001。重新启动后一切正常,而下一个异常发生... 在lumia 523上测试应用,其从wp 8.1升级到wp 10。 以下是整页代码:http://pastebin.com/2aNX9T5m 有什么想法有什么不对?是Windows 10移动问题吗? 在此先感谢您的帮助。 :)

0 个答案:

没有答案