Barcode reading Delphi xe7, event after intent not triggering

ThisGuy picture ThisGuy · Oct 3, 2014 · Viewed 8.7k times · Source

In my app, developed with XE7 for Android/iOS, I have a form for scanning barcodes. Upon a found barcode, my app validates whether it is an acceptable barcode or not. Following tutorials here: http://www.fmxexpress.com/qr-code-scanner-source-code-for-delphi-xe5-firemonkey-on-android-and-ios/

Currently I am testing on Android and I am able to integrate scanning and reading of barcodes, but the 'onBarCode' event does not fire when returned from the shared Activity of finding the barcode. Same code worked well with previous versions of Rad Studio ( XE4, XE5, XE6) but now in XE7 it does not.

Here are some snippets of code:

...
begin
    Scanner := TAndroidBarcodeScanner.Create(true);
    Scanner.OnBarCode := BarcodeHandler;
    Scanner.Scan;
end;

procedure TmScannerForm.BarcodeHandler(Sender: TAndroidBarcodeScanner;
  BarCode: String);
begin
  text1.Text := Barcode;
  memo1.PasteFromClipboard;
  AddBarcode(BarCode, true);
end;

AddBarCode is the even I used to validate and add barcode to a list, but I didnt include it, because that code isn't the problem - it's not even triggering. The Text1.text:=Barcode and memo1.paseFromClipboard were in their for validating the even wasn't firing too. I can confirm the barcodes are being read because if I tap and manually paste, the barcode shows.

Why is this not working on XE7 as it did in previous versions of Rad Studio?

Answer

etherel picture etherel · Oct 24, 2014

Andrea Magni has a more elegant solution than the timer on his blog based on event handling.

I would comment to send the link but I don't have enough reputation. The link to his blog is :

http://blog.delphiedintorni.it/2014/10/leggere-e-produrre-barcode-con-delphi.html

Maybe this can help you. The blog is in Italian though but the sources are provided and are explaining by themselves.