i m trying to make an app which uses Xamarin & ZXing to read qr codes which implicates web site adressess and after successful qr read the app opens the link in browser. but my problem is: after opening the link in browser and returning to the qr reader app( either via back button or closing the browser with home button) my app doesnt read further qr codes.("read qr once go to website via browser then return browser and continue reading qr's and opening them" is what i m trying to achive)
what i have tried so far:
- creating a button to set the scanView.IsScanning to true when clicked. result: still doesnt read another qr after first one and opening in the browser
- using onDisappearing and onAppearing to change the scanView.IsScanning to true so it can read again
- in App.xml " MainPage = new MainPage();" added this code line to onResume and onSleep but this approach is basically opening the app from scratch and too taxing for older devices and takes some time
- tried looking solutions from other people's qr problems but didnt/couldnt find solution i m seeking so far
how can i make the qr reader to read another qr after one read and making action about it. thanks in advance
ps: i followed Redth's github file and other people who implemented this
codes from mainpage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void scanView_OnScanResult(ZXing.Result result)
{
if (result.Text != null && result.Text.Contains("ramakbilisim"))
{
Browser.OpenAsync(result.Text,BrowserLaunchMode.SystemPreferred);
}
}
protected override void OnAppearing()
{
base.OnAppearing();
scanView.IsScanning = true;
}
protected override void OnDisappearing()
{
base.OnDisappearing();
scanView.IsScanning = false;
}
}
codes from mainpage.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
mc:Ignorable="d"
x:Class="RamakDenemeQr.MainPage">
<StackLayout Padding="0,0,0,10">
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Ramak Deneme Qr" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<zxing:ZXingScannerView
x:Name="scanView"
OnScanResult="scanView_OnScanResult"
IsScanning="False"
WidthRequest="300"
HeightRequest="400"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
/>
</StackLayout>