jZBarcodeScannerView crash application lazarus / 43-Android ---------------------------------------------------------------------- kristof.project · 2021-04-27 22:33 hello, i create a application LAMW4 [gui] with a main form and 3 other "child" (actRecyclabe). i can switch without probleme In a child form (scanform) i have a jZBarcodeScannerView. (the permission camera is ok) i can take many photo of codebar, i can close without probleme and go to the main form, but if i want re-open the scanform the app crash. so i re-open the app, i can have scanform and if close it without scan there is no probleme. the procedure use to call the scanform if you need Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (...)procedure TFbase.BscanClick(Sender: TObject);begin  if(Fscan = nil) then begin   gApp.CreateForm(TFscan, Fscan);   Fscan.InitShowing(gApp);   Fscan.BarCode.Visible:=false;   Fscan.Bproduit.Visible:=true;   fscan.Bsignaler.Visible:=false;   Fscan.Bproduit.Text:='Commercer à scanner';   DataBase.DataBaseName:='myData.db';   Fbase.DataBase.Select('SELECT * FROM Produits');   Fscan.totprod.Text:=IntToStr(Fbase.DataBase.Cursor.GetRowCount)+   ' produits dans la base'; end else begin   Fscan.Show;   DataBase.DataBaseName:='myData.db';   Fbase.DataBase.Select('SELECT * FROM Produits');   Fscan.totprod.Text:=IntToStr(Fbase.DataBase.Cursor.GetRowCount)+   ' produits dans la base';   Fscan.Bproduit.Text:='Commercer à scanner';   fscan.Bsignaler.Visible:=false;   Fscan.BarCode.Visible:=false;   Fscan.Bproduit.Visible:=true; end;end; (...) ---------------------------------------------------------------------- Mongkey · 2021-04-28 00:14 just make sure to turn off barcode scan on exit/closing form -> turn on, on barcoder scanner form show ---------------------------------------------------------------------- kristof.project · 2021-04-28 07:44 Quote from: Mongkey on April 28, 2021, 02:14:50 amjust make sure to turn off barcode scan on exit/closing form -> turn on, on barcoder scanner form show thank for the idea.i found a procedure stopscan() in jZBarcodeScannerView so my code in OnScannerResult i use it like this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure {YouForm}.{Your_jZBarcodeScannerView}Result(Sender: TObject; codedata: string; codeformat: TBarcodeFormat); begin  {Your_jZBarcodeScannerView}.stopscan();(...)end;   if close my scanform an re-open there no crash. How i can suggest a modification of AppZBarcodeScannerViewDemo1 ? ---------------------------------------------------------------------- Mongkey · 2021-04-28 07:57 I think u should put your code here, i do barcode scanning using lamw, error never comes out by following above procedure. May be we got volunteer to exam your code. ---------------------------------------------------------------------- kristof.project · 2021-04-28 08:08 Quote from: Mongkey on April 28, 2021, 09:57:34 amI think u should put your code here, i do barcode scanning using lamw, error never comes out by following above procedure. May be we got volunteer to exam your code. did you work multiple form ? because i work with, see my previous message. ---------------------------------------------------------------------- Mongkey · 2021-04-28 08:22 More than 20 forms, ---------------------------------------------------------------------- kristof.project · 2021-04-28 08:29 so the buttonclick to show the scanform Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFbase.BscanClick(Sender: TObject);begin  if(Fscan = nil) then begin   gApp.CreateForm(TFscan, Fscan);   Fscan.InitShowing(gApp);   Fscan.BarCode.Visible:=false;   Fscan.Bproduit.Visible:=true;   fscan.Bsignaler.Visible:=false;   Fscan.Bproduit.Text:='Commercer à scanner';   DataBase.DataBaseName:='myData.db';   Fbase.DataBase.Select('SELECT * FROM Produits');   Fscan.totprod.Text:=IntToStr(Fbase.DataBase.Cursor.GetRowCount)+   ' produits dans la base'; end else begin   Fscan.Show;   DataBase.DataBaseName:='myData.db';   Fbase.DataBase.Select('SELECT * FROM Produits');   Fscan.totprod.Text:=IntToStr(Fbase.DataBase.Cursor.GetRowCount)+   ' produits dans la base';   Fscan.Bproduit.Text:='Commercer à scanner';   fscan.Bsignaler.Visible:=false;   Fscan.BarCode.Visible:=false;   Fscan.Bproduit.Visible:=true; end;end;  the buttonscan on formscan Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFscan.BscanClick(Sender: TObject);begin  if IsRuntimePermissionGranted('android.permission.CAMERA') then begin   Bproduit.Visible:=false;   BarCode.Visible:=true;   BarCode.Scan(); end;end; an the procedure onscanresult Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFscan.BarCodeScannerResult(Sender: TObject; codedata: string;  codeformat: TBarcodeFormat);  begin  barcode.StopScan();  if Ord(codeformat)<>13 then    begin      infoProd.Text:='';      Ean.Text:='EAN : Code non valide';      barcode.visible:=false;    end  else    begin      Ean.Text:='EAN : '+codedata;      Fbase.DataBase.Select('SELECT * FROM Produits WHERE EAN='+codedata);    if Fbase.DataBase.Cursor.GetRowCount<>0 then        begin          infoProd.Text:=Fbase.DataBase.Cursor.GetValueAsString('nom');        Bproduit.visible:=true;          barcode.visible:=false;          previmg.visible:=true;          self.Vibrate(125);          sleep(250);          self.Vibrate(125);          bsignaler.Visible:=false;          previmg.SetImage(jBitmap1.LoadFromAssets(codedata+'.jpg'));         end      else        begin          previmg.visible:=false;          bproduit.visible:=true;          barcode.visible:=false;          infoProd.Text:='Produit non trouvé';          Ean.Text:='EAN : '+codedata;          self.Vibrate(125);          bsignaler.Visible:=true;          Dean:=codedata;        end;    end;end; ---------------------------------------------------------------------- Mongkey · 2021-04-28 08:59 Try this code on showing your barscan form, Fscan.init(gapp) then fscan.show. Dont forget to stop bar scan on exit activity/form. Even giving result or not on scanning. ---------------------------------------------------------------------- kristof.project · 2021-04-28 09:35 Quote from: Mongkey on April 28, 2021, 10:59:44 amTry this code on showing your barscan form, Fscan.init(gapp) then fscan.show. Dont forget to stop bar scan on exit activity/form. Even giving result or not on scanning. added on the onclose procedure