(SOLVED) LAMW - intercept stand by cellphone lazarus / 43-Android ---------------------------------------------------------------------- xinyiman · 2021-09-24 07:14 Hi, using the jZBarcodeScannerView component I noticed that when the phone goes into standby while jZBarcodeScannerView is scanning, the application crashes. How can I solve the problem? Thanks ---------------------------------------------------------------------- loaded · 2021-09-24 16:43 Hi, since I don't know your device I guess the problem and solution. Not closing the barcode scanner in the stop method of the activity triggered without entering the standby mode, and then not restarting the barcode scanner in the resume method that works when returning to the activity! Regarding the subject, I made a few minor changes in the AppZBarcodeScannerViewDemo1 sample and made it work smoothly for me. Tried and Runs in Standby Mode without Problem. 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 {Hint: save all files to location: C:\android\workspace\AppZBarcodeScannerViewDemo1\jni }unit unit1; {$mode delphi} interface uses  Classes, SysUtils, AndroidWidget, Laz_And_Controls, zbarcodescannerview;  type   { TAndroidModule1 }   TAndroidModule1 = class(jForm)    jBitmap1: jBitmap;    jButton1: jButton;    jButton2: jButton;    jTextView1: jTextView;    jZBarcodeScannerView1: jZBarcodeScannerView;    procedure AndroidModule1ActivityPause(Sender: TObject);    procedure AndroidModule1ActivityResume(Sender: TObject);    procedure AndroidModule1JNIPrompt(Sender: TObject);    procedure AndroidModule1RequestPermissionResult(Sender: TObject;      requestCode: integer; manifestPermission: string;      grantResult: TManifestPermissionResult);    procedure jButton1Click(Sender: TObject);    procedure jButton2Click(Sender: TObject);    procedure jZBarcodeScannerView1Click(Sender: TObject);    procedure jZBarcodeScannerView1ScannerResult(Sender: TObject;      codedata: string; codeformat: TBarcodeFormat);  private    {private declarations}  public    {public declarations}  end; var  AndroidModule1: TAndroidModule1;  Jzbsc:Boolean=false;implementation  {$R *.lfm}   { TAndroidModule1 } procedure TAndroidModule1.jButton1Click(Sender: TObject);begin  jBitmap1.LoadFromAssets('codebar1.png');  //or qrcode1.png  jZBarcodeScannerView1.Scan(jBitmap1.GetImage());end; procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);begin   if IsRuntimePermissionNeed() then   // that is, if target API >= 23   begin     ShowMessage('Requesting Runtime Permission....');     Self.RequestRuntimePermission('android.permission.CAMERA', 1113);   //handled by OnRequestPermissionResult   endend; procedure TAndroidModule1.AndroidModule1ActivityPause(Sender: TObject);begin  if Jzbsc then jZBarcodeScannerView1.StopScan();end; procedure TAndroidModule1.AndroidModule1ActivityResume(Sender: TObject);begin  if Jzbsc then jZBarcodeScannerView1.Scan();end; procedure TAndroidModule1.AndroidModule1RequestPermissionResult(  Sender: TObject; requestCode: integer; manifestPermission: string;  grantResult: TManifestPermissionResult);begin  case requestCode of    1113:begin            if grantResult = PERMISSION_GRANTED  then              ShowMessage('Success! "'+ manifestPermission + '" granted!')          else//PERMISSION_DENIED                ShowMessage('Sorry... "android.permission.CAMERA" permission not granted... ' );         end;  end;end; procedure TAndroidModule1.jButton2Click(Sender: TObject);begin   if IsRuntimePermissionGranted('android.permission.CAMERA') then  begin   jZBarcodeScannerView1.Scan();     Jzbsc:=true;  end;end; procedure TAndroidModule1.jZBarcodeScannerView1Click(Sender: TObject);begin  if IsRuntimePermissionGranted('android.permission.CAMERA') then  begin   jZBarcodeScannerView1.Scan();  end;end; procedure TAndroidModule1.jZBarcodeScannerView1ScannerResult(Sender: TObject;  codedata: string; codeformat: TBarcodeFormat);begin  ShowMessage('codedata = '+ codedata + '    ::    codeformat = ' + IntToStr(Ord(codeformat)));end; end. ---------------------------------------------------------------------- jmpessoa · 2021-09-24 17:33 Quote I made a few minor changes in the AppZBarcodeScannerViewDemo1 ... Updated in  LAMW github! Thank you! ---------------------------------------------------------------------- xinyiman · 2021-09-26 21:12 Perfect. Thank you