i use this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace UBIK_Beauty_app
{
public partial class PageScanner : ContentPage
{
public PageScanner()
{
InitializeComponent();
}
void ZXingScannerView_OnScanResult(ZXing.Result result)
{
Device.BeginInvokeOnMainThread(() =>
{
scanResultText.Text = result.Text + " (type: " + result.BarcodeFormat.ToString() + ")";
Application.Current.MainPage.Navigation.PopAsync();
});
}
private void AvviaScanner(object sender, EventArgs args)
{
//fotoCamera.IsVisible = true;
// fotoCamera.IsScanning = true;
}
}
}
it works only the first time you open the page, if you,
after you get the barCode by scanning, go to previuos page and then reOpen this page the camera doesn'TSCAN!!!!!!
Why don't you tray and help me????
THANKS
Riccardo DariaPosted May 28, 2023, 5:40 PM
No anyone can help me?????
Riccardo DariaPosted May 26, 2023, 9:42 AM
this page: (PageScanner) is called from a previous page, and the method avviaScanner isn't usefull not is used!!
when i call this page for the first time the scanner works, after the scnning, the app need to go back at the prevous page, and from this previous page you call another time the PageScanner for a new scan, but the second time the scann doesn't work!!!!!
I hope i gave you the correct scenarious
Thanks
Mohamed Azarudeen ZPosted May 26, 2023, 9:18 AM
Hi Ric
To resolve this issue, you can try implementing the following changes:
Remove the line
Application.Current.MainPage.Navigation.PopAsync();from theZXingScannerView_OnScanResultmethod. This line is causing the page to be popped from the navigation stack, which might be the reason the camera is not scanning again when you navigate back to the page.Modify the
AvviaScannermethod to reset theIsScanningproperty of theZXingScannerViewtotruebefore navigating to the scanner page. This will ensure that the camera starts scanning again when you return to the page. Here's an example of how you can modify the method:With these changes, the camera should resume scanning when you navigate back to the page, allowing you to scan barcodes multiple times without any issues.
I hope this helps! Let me know if you have any further questions.