I'm using qr code scanner in Xamarin forms. plugin is Zxing.net.mobile. I want to scan continuously, for that i wrote a code. it's working in IOS but in android it's not working. Actually the process is First the user will scan a QR Code the he will get he result and then he will be showed with a popup " Do you want to continue ". He clicks "yes", the scanner should start again. But the page is struck in android. Can you help me in this issue ?
private async Task Scanner_OnScanResultAsync(ZXing.Result result)
{
Device.BeginInvokeOnMainThread(async () =>
{
string password = App.LoggedInUser.Password;
scanner.IsScanning = false;
App.ScannedResult = result.Text;
// await DisplayAlert("Scanned Qrcode", result.Text, "OK");
if (!(App.ScannedResult.StartsWith("MSS") && App.ScannedResult.Length == 10))
{
await DisplayAlert("", "It's a Invalid QRCode", "Okay");
await Navigation.PushAsync(new DashboadPages.DashboardPage());
}
else
{
try
{
details = await hs.GetDeviceByQRCode(App.LoggedInUser.LoginId, password, result.Text);
if (details.Details == null && details.Created == null && details.History == null)
{
await Navigation.PushPopupAsync(new MacIdPopUpPage(DeviceMacIDChange, DeviceIdentifier)); // popUp
}
else
{
await DisplayAlert("Error", "This QR Code is associated with an existing item in MINT", "Okay");
await Navigation.PopToRootAsync();
}
}
catch (Exception ex)
{
await DisplayAlert("", ex.Message, "");
}
}
});
}
public async void DeviceMacIDChange(object sender, string deviceIdentifier)
{
ItemDetail.DeviceIdentifier = deviceIdentifier; // updating macId
var item = new GenericInputModel
{
HubbleId = App.LoggedInUser.LoginId,
DisplayName = App.LoggedInUser.FName,
Password = App.LoggedInUser.Password,
UpdationInfo = new UpdationInfoModel
{
ItemDetail = ItemDetail
}
};
var response = await hs.UpdateDeviceDetails(item, details.Id);
if (response.Message == "Document has been updated successfully")
{
await DisplayAlert("Success", $"Your Item {item.UpdationInfo.ItemDetail.ItemName} has been saved to inventory", "Okay");
}
else
{
await DisplayAlert("Failed", response.Message, "Okay");
}
bool yes = await DisplayAlert("Do you want to continue scanning?", "", "Continue", "Exit");
if (yes)
{
scanner.IsScanning = true;
}
else
{
await App.RefreshDataAsync();
await Navigation.PopToRootAsync(); // Exit
}
}