ZXing.Net.Mobile: ZXing Scanner Camera is not activating in UWP and WP 8.1
I am using the example code from the ZXing page . Details are : Operating System : Windows 10 Pro N Visual Studio Enterprise 2015 Xamarin.Forms 2.3.1…114 ZXing.Net.Mobile 2.1.47 ZXing.Net.Mobile.Forms 2.1.4.7
I am using below code
btnScan.Clicked+=async(sender,e)=>{
var scanPage = new ZXingScannerPage ();
await Navigation.PushModalAsync (scanPage);
scanPage.OnScanResult += (result) =>
{
scanPage.IsScanning = false;
Device.BeginInvokeOnMainThread (async () =>
{
await Navigation.PopModalAsync ();
await DisplayAlert("Scanned Barcode", result.Text, "OK");
});
};
}
Also I have added the below line in the MainPage.xml file of the UWP project just before LoadApplication method call ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer.Init();
Also I have provided access to the WebCam from the application manifest.
When I run the application in Debug or Release mode in the emulator then it opens the scanner but small black/white /red /green square comes and computer webcam is not accessed. When I run it as windows 10 app then nothing comes, only blank screen comes. When I run it in the real windows 10 mobile, then scanner opens but camera doesn’t opens, the white screen with red line opens and camera doesn’t activates. The same thing happens with WIndows 8.1 also.
Any help would be deeply appreciated. I have wasted lot of time to explore the internet used almost every combination. If anyone have the solution please please provide me.
Note: The above code works fine for Android and I am able to scan the bar code and QR code.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (2 by maintainers)
@F1nZeR yes!
The only lines you actually need are: assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingScannerViewRenderer).GetTypeInfo().Assembly); and assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingScannerPage).GetTypeInfo().Assembly);
However, if no camera is available, the screen just displays a white background, which causes the app to get rejected from the windows store.
@faceoffers28 , that did the trick! for anyone interested: just add these lines in your
App.xaml.cs@nicolabeghin have you added “webcam” permission?
Can confirm, the “assembliesToInclude” method fixed this issue for me.
In App.xaml.cs, procedure “OnLaunched”, replace
Xamarin.Forms.Forms.Init(e);withBut the 2.1.47 NuGet packages don’t install the Winphone library to the win phone project. So no init is available.