Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Barcode reader for iOS AND Android?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 35 - Last Post: Jul 25, 2016 9:23 AM Last Post By: Chris Dunn
martin moore

Posts: 4
Registered: 4/8/13
Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2013 3:57 AM
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.
Frank Staal

Posts: 115
Registered: 12/9/99
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2013 5:58 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

I don't have the urls here but search for ZXing for Android and ZBar for iOS. I create my iOS apps in Xcode where I use ZBar but I doubt it won't work under FireMonkey. Good luck
Auto Computers

Posts: 73
Registered: 7/8/05
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2013 6:49 AM   in response to: martin moore in response to: martin moore
I have not done anything in Andriod yet, but in Windows a usb barcode reader
acts as a
keyboard when installed. If you can get a usb barcode reader with a driver
for Andriod you
may be able to use it in a similar way.

Godfrey

<martin moore> wrote in message news:620029 at forums dot embarcadero dot com...
Hi, I've foolishly agreed to produce a barcode reader App., but can't find
a component/library for Android. I can't believe there isn't one (kind of
surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.
John Whitham

Posts: 2
Registered: 7/15/01
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2013 9:44 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

I don't think it's currently possible with Android. I've succeeded in calling the ZXing Java library using TJIntent, but there seems no way to assign a callback function to obtain the result.
John Whitham

Posts: 2
Registered: 7/15/01
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2013 5:02 AM   in response to: John Whitham in response to: John Whitham
John Whitham wrote:
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

I don't think it's currently possible with Android. I've succeeded in calling the ZXing Java library using TJIntent, but there seems no way to assign a callback function to obtain the result.

Okay, I take that back. It seems that when focus returns to the application the result of the scan is on the clipboard. Not sure the following is all correct, but it is working for me.

Uses
  androidapi.JNI.GraphicsContentViewText, androidapi.jni.JavaTypes, fmx.helpers.android;
  
Procedure GetBarcode;
var
  intent: jintent;
begin
  intent := tjintent.Create;
  intent.setAction(stringtojstring('com.google.zxing.client.android.SCAN'));
  intent.putExtra(tjintent.JavaClass.EXTRA_TEXT,stringtojstring('"SCAN_MODE", "PRODUCT_MODE"'));
  sharedactivity.startActivityForResult(intent,0);
  edit1.PasteFromClipboard;
end;


Sorry to contradict myself again.

Simply pasting into an edit at the end of that code is just as likely to cause a crash or hang as to get the result. I've put togeteher a rough web page to explain better http://john.whitham.me.uk/xe5/

Edited by: John Whitham on Oct 11, 2013 5:04 AM

Edited by: John Whitham on Oct 11, 2013 1:56 PM
Scott Pritchard

Posts: 7
Registered: 1/3/12
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2013 4:49 PM   in response to: John Whitham in response to: John Whitham
John Whitham wrote:
John Whitham wrote:
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

I don't think it's currently possible with Android. I've succeeded in calling the ZXing Java library using TJIntent, but there seems no way to assign a callback function to obtain the result.

Okay, I take that back. It seems that when focus returns to the application the result of the scan is on the clipboard. Not sure the following is all correct, but it is working for me.

Uses
  androidapi.JNI.GraphicsContentViewText, androidapi.jni.JavaTypes, fmx.helpers.android;
  
Procedure GetBarcode;
var
  intent: jintent;
begin
  intent := tjintent.Create;
  intent.setAction(stringtojstring('com.google.zxing.client.android.SCAN'));
  intent.putExtra(tjintent.JavaClass.EXTRA_TEXT,stringtojstring('"SCAN_MODE", "PRODUCT_MODE"'));
  sharedactivity.startActivityForResult(intent,0);
  edit1.PasteFromClipboard;
end;


Sorry to contradict myself again.

Simply pasting into an edit at the end of that code is just as likely to cause a crash or hang as to get the result. I've put togeteher a rough web page to explain better http://john.whitham.me.uk/xe5/

Edited by: John Whitham on Oct 11, 2013 5:04 AM

Edited by: John Whitham on Oct 11, 2013 1:56 PM

Just to expand on this, it seems like scanning QR codes wouldn't be much different;

 Procedure GetQRcode;
 var
   intent: jintent;
 begin
   intent := tjintent.Create;
   intent.setAction(stringtojstring('com.google.zxing.client.android.SCAN'));
   intent.putExtra(tjintent.JavaClass.EXTRA_TEXT,stringtojstring('"SCAN_MODE","ONE_D_MODE,QR_CODE_MODE,PRODUCT_MODE,DATA_MATRIX_MODE"'));
   sharedactivity.startActivityForResult(intent,0);
   edit1.PasteFromClipboard;
 end;


It's untested, but it is quite literally just a case of changing the second argument (at least according to some quick Googling). I figure that QR is becoming quite popular for social applications while barcode is obviously good for price comparison or general shopping (or even inventory management) applications.
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2013 5:52 PM   in response to: Scott Pritchard in response to: Scott Pritchard
Hi
I would love to a get QR reader working
so that users can scan a QR code on a web site to get that web sites URL into the app, to save typing it in
sort of thing

the code at
http://john.whitham.me.uk/xe5/
compiles and runs
with the change to the QR above

but does not nothing when you click on the button (i.e just hangs)

I have not done thing anything about zxing ...should I have?
thanks!
hold the phone
ok, I installed
https://play.google.com/store/apps/details?id=com.google.zxing.client.android

on my phone (which is free to use)

and bingo, it works! :)

Edited by: Brian Hamilton on Oct 12, 2013 5:54 PM
Scott Pritchard

Posts: 7
Registered: 1/3/12
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2013 11:35 PM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
Brian Hamilton wrote:
Hi
I would love to a get QR reader working
so that users can scan a QR code on a web site to get that web sites URL into the app, to save typing it in
sort of thing

the code at
http://john.whitham.me.uk/xe5/
compiles and runs
with the change to the QR above

but does not nothing when you click on the button (i.e just hangs)

I have not done thing anything about zxing ...should I have?
thanks!
hold the phone
ok, I installed
https://play.google.com/store/apps/details?id=com.google.zxing.client.android

on my phone (which is free to use)

and bingo, it works! :)

Edited by: Brian Hamilton on Oct 12, 2013 5:54 PM

Indeed. I already had 'QRDroid' installed while testing out the code, but installing the ZXING client worked when combined with the code by John. It's a little bit fussy at times, but that's likely because the device I'm using for dev. is extremely low end (with a 0.3MP camera). It could be that QRDroid would have worked but that I wasn't steady enough when trying to scan.

The great thing about QR is that it can store any string (up to a length of about 4000 characters). Unfortunately, I couldn't find any FMX compatible component for generating QR codes, mostly due to the differences in VCL and FMX bitmaps. However, Rodrigo/RRUZ did create some code a long time ago that I've verified does work by using a Google provided API for generating codes; http://theroadtodelphi.wordpress.com/2010/12/06/generating-qr-codes-with-delphi/

For me, my project is 3 parts - A desktop app, an Android app, and a web API powered by PHP and MySQL DB's. Instead of having users need to remember long codes to link the desktop and android data together, I can basically generate a unique QR code (using system ID's and timestamp to generate a hash) and let the users photo their screen and then perhaps setup a password or pin so that only they can access it (i.e. first time it's scanned, they set the pin and then it's requested if someone else scans the same QR code if they want to gain access through another Android device) -- or perhaps let them provide an email address and use Android device ID's and email verification. I could basically use this as either a secure remote, or as a mobile data display.

Of course it could be used for scanning website addresses and opening the browser, but I figure that there's a lot of potential for image-based authentication (used alongside more traditional methods) when it comes to multi-platform and mobile.
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2013 12:59 PM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
Now I am looking for how to do QR reading in iOS
now that this is working on android :)
any tips/links?
( I have done some searching but nothing is standing out)
thanks!
Brian

edit , just found this:
http://blog.naver.com/simonsayz/120190201608
but I get an error with {$Link libiconv.dylib} // Link Apple Dynamic Library. User Dynamic Lib can't use.

i.e cant find that file error

Edited by: Brian Hamilton on Oct 13, 2013 1:33 PM

Edited by: Brian Hamilton on Oct 13, 2013 1:40 PM
Synaptica Srl U...

Posts: 14
Registered: 6/26/08
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2014 9:24 AM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
to implement the "startactivityforresult" in Delphi XE5 the most structured sample that i found is :

http://blog.csdn.net/flcop/article/details/13018911


Brian Hamilton wrote:
Now I am looking for how to do QR reading in iOS
now that this is working on android :)
any tips/links?
( I have done some searching but nothing is standing out)
thanks!
Brian

edit , just found this:
http://blog.naver.com/simonsayz/120190201608
but I get an error with {$Link libiconv.dylib} // Link Apple Dynamic Library. User Dynamic Lib can't use.

i.e cant find that file error

Edited by: Brian Hamilton on Oct 13, 2013 1:33 PM

Edited by: Brian Hamilton on Oct 13, 2013 1:40 PM
Chris Dunn

Posts: 160
Registered: 8/22/11
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2016 9:23 AM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
but I get an error with {$Link libiconv.dylib} // Link Apple Dynamic Library. User Dynamic Lib can't use.

so, you got the libzbar.a library from here or somewhere similar:
https://github.com/null09264/ZBarSDK-for-iOS
added to your project directory

next keep in mind you cannot run this library in the simulator, which im guessing is the cause of your error.
line lily

Posts: 1
Registered: 11/17/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 17, 2013 1:27 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.
Hey, here is a professional barcode software site from which our company has been using barcode tools for years. I made a search for barcode reader for iOS. But I only found barcode generator for iOS. You may check and contact the supplier for barcode reader for iOS. Barcode tools there are not bad.
mariah sharp

Posts: 6
Registered: 9/12/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2013 7:10 PM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.
hey,i still wanna find a barcode reader for my android,but i searched on google,found many resources are just about .net barcode reader or java barcode reader,the former one seems not available in phone,but the latter one...just wondering...
Alf Christopher...

Posts: 25
Registered: 10/10/98
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2013 9:58 AM   in response to: mariah sharp in response to: mariah sharp
mariah sharp wrote:
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.
hey,i still wanna find a barcode reader for my android,but i searched on google,found many resources are just about .net barcode reader or java barcode reader,the former one seems not available in phone,but the latter one...just wondering...

One of the Coderage 8 sessions was about using a Java code in order to use the barcode reader.
hongdi da

Posts: 2
Registered: 6/26/14
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2014 12:14 AM   in response to: mariah sharp in response to: mariah sharp
Robert Lawrence

Posts: 1
Registered: 10/11/99
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 11, 2013 8:24 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

Someone else mentioned the CodeRage 8 session. Here's the info:

http://blog.blong.com/(on his blog go down to My CodeRage session files)

"The second session is Accessing the Android API and looks at how Delphi-written Android apps can talk to the Android SDK classes. We look at the Java bridge and see how it is used to import Android APIs. We’ll also look at how to pull in APIs that are not already imported by Delphi’s RTL. We also look at how to add a splash screen to an Android app to cover up the startup time on anything other than the fastest devices, how to add Android menus to an app and how to launch external activities and get results back from them."

This examples package from Brian Long has a Android barcode example in it.
http://blong.com/Downloads/AccessingTheAndroidAPI.7z
makaveil jojo

Posts: 4
Registered: 12/29/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 28, 2013 8:11 PM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

Zxing has free barcode library and some other components for Android. You might get something useful over there. And me myself for now I'm using a paid Android barcode font to generate images and Zxing reader to read.

Oliver Hager

Posts: 37
Registered: 8/13/10
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2013 5:42 AM   in response to: makaveil jojo in response to: makaveil jojo
makaveil jojo wrote:
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

Zxing has free barcode library and some other components for Android. You might get something useful over there. And me myself for now I'm using a paid Android barcode font to generate images and Zxing reader to read.


Hi

Is there any way to include the Zxing library in the project itself so that users dont have to download zxing before using the application ?
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2013 6:46 AM   in response to: Oliver Hager in response to: Oliver Hager
Oliver Hager wrote:
Is there any way to include the Zxing library in the project itself so that users dont have to download zxing before using the application ?

Merging dex files as described by Brian Long here:
http://blog.blong.com/2013/10/my-coderage-session-files.html

Hopefully in the future the IDE will make this easier.

Best Regards,
Cristian Peta
Pedro Alegria

Posts: 13
Registered: 4/23/08
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2013 10:09 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

Try this solution you must install om.google.zxing barcode reader !

unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.platform, fmx.helpers.android,
androidapi.JNI.GraphicsContentViewText, androidapi.jni.JavaTypes, FMX.Edit,
FMX.StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
ClipService: IFMXClipboardService;
Elapsed: integer;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
var intent: jintent;
begin
if assigned(ClipService) then
begin
clipservice.SetClipboard('nil');
intent := tjintent.Create;
intent.setAction(stringtojstring('com.google.zxing.client.android.SCAN'));
intent.putExtra(tjintent.JavaClass.EXTRA_TEXT, stringtojstring('"SCAN_MODE", "CODE_39"'));
sharedactivity.startActivityForResult(intent,0);
Elapsed := 0;
timer1.Enabled := true;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
if not TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, IInterface(ClipService)) then
ClipService := nil;

Elapsed := 0
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin

if (ClipService.GetClipboard.ToString <> 'nil') Then
begin
timer1.Enabled := false;
edit1.Text := ClipService.GetClipboard.ToString;
end;

end;
Erik Salaj

Posts: 144
Registered: 12/23/11
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 17, 2013 5:56 AM   in response to: martin moore in response to: martin moore
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

See optical barcode recognition component for Android:

http://www.winsoft.sk/aobr.htm

Erik Salaj, WINSOFT
Cromwell keller

Posts: 2
Registered: 7/27/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 2, 2014 8:11 PM   in response to: Erik Salaj in response to: Erik Salaj
Erik Salaj wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

See optical barcode recognition component for Android:


Barcode reading tool combined within image reading and processing application can be implement within .net framework or java technique to develop barcode reading app on IOS or android operating systmes.
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 2, 2014 10:37 PM   in response to: Cromwell keller in response to: Cromwell keller
will that work with XE5 ? (Android and iOS)
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2014 7:16 PM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
I see TMS have a Blog post about QR reader for iOS:
http://www.tmssoftware.com/site/blog.asp
:)
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 12, 2014 3:05 PM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
Brian Hamilton wrote:
I see TMS have a Blog post about QR reader for iOS:
http://www.tmssoftware.com/site/blog.asp
:)

now there is a component for android too via that blog
very easy to use components...2 lines of code needed
and they work great :)
Erik Salaj

Posts: 144
Registered: 12/23/11
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2014 6:40 PM   in response to: Erik Salaj in response to: Erik Salaj
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Barcode component for iOS (testing version):

http://www.winsoft.sk/download/iobr.exe

Erik Salaj, WINSOFT
Pedro Alegria

Posts: 13
Registered: 4/23/08
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 4, 2014 5:03 AM   in response to: martin moore in response to: martin moore
Here is the code that works !

Make a unit:

unit Android.BarcodeScanner;

interface

// Inspired by http://john.whitham.me.uk/xe5/
// Implemented by Jim McKeeth - jim dot mckeeth at embarcadero dot com - www.delphi.org

// Must have the ZXing barcode scanner installed
// https://play.google.com/store/apps/details?id=com.google.zxing.client.android
// See the ZXing Google Code page here https://code.google.com/p/zxing/ for more info the library and licensing.

// The barcode is tranfered via the clipboard, but the clipboard is preserved.

uses
FMX.platform, fmx.helpers.android, System.Rtti, FMX.Types, System.Classes,
System.SysUtils,
androidapi.JNI.GraphicsContentViewText,
androidapi.jni.JavaTypes, FMX.StdCtrls, FMX.Edit;

type
TAndroidBarcodeScanner = class;
TAndroidBarcodeEvent = procedure (Sender: TAndroidBarcodeScanner; ABarcode: string) of object;
TAndroidBarcodeAnonEvent = reference to procedure(ABarcode: string);
TAndroidBarcodeScanner = class(TComponent)
private
FClipService: IFMXClipboardService;
FOldClipboard: TValue;
FMonitorClipboard: Boolean;
FOnBarcode: TAndroidBarcodeEvent;
FHandler: TAndroidBarcodeAnonEvent;
const ClipboardCanary = 'waiting';
procedure CallScan(AScanCmd: string);
procedure GetBarcodeValue;
public
{ Public declarations }
type TBarcodeMode = (bmOneD, bmQRCode, bmProduct, bmDataMatrix);
type TBarcodeModes = set of TBarcodeMode;
function HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
constructor Create(RegisterApplicationEventHandler: Boolean = True);
procedure Scan; overload;
procedure Scan(AMode: TBarcodeMode); overload;
procedure Scan(AModes: TBarcodeModes); overload;
procedure Scan(AMode: TBarcodeMode; AHandler: TAndroidBarcodeAnonEvent); overload;
procedure Scan(AModes: TBarcodeModes; AHandler: TAndroidBarcodeAnonEvent); overload;
const AllBarcodeModes: TBarcodeModes = [bmOneD, bmQRCode, bmProduct, bmDataMatrix];
property OnBarcode: TAndroidBarcodeEvent read FOnBarcode write FOnBarcode;
private
const BarcodeModes: array [bmOneD .. bmDataMatrix] of string =
('ONE_D_MODE', 'QR_CODE_MODE', 'PRODUCT_MODE', 'DATA_MATRIX_MODE');
function GetModeString(AModes: TBarcodeModes): string;
end;

implementation

{ TAndroidBarcodeScanner }

constructor TAndroidBarcodeScanner.Create(RegisterApplicationEventHandler: Boolean);
var
aFMXApplicationEventService: IFMXApplicationEventService;
begin
FMonitorClipboard := false;

if not TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, IInterface(FClipService)) then
FClipService := nil;

if RegisterApplicationEventHandler then
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)
else
Log.d('Application Event Service is not supported.');
end;
end;

function TAndroidBarcodeScanner.HandleAppEvent(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;
begin

if FMonitorClipboard and (AAppEvent = aeBecameActive) then
begin
GetBarcodeValue;
end;

end;

procedure TAndroidBarcodeScanner.Scan(AMode: TBarcodeMode);
begin
Scan([AMode]);
end;

procedure TAndroidBarcodeScanner.Scan;
begin
Scan(AllBarcodeModes);
end;

procedure TAndroidBarcodeScanner.Scan(AModes: TBarcodeModes);
begin
CallScan(GetModeString(AModes));
end;

procedure TAndroidBarcodeScanner.Scan(AModes: TBarcodeModes;
AHandler: TAndroidBarcodeAnonEvent);
begin
FHandler := AHandler;
Scan(AModes);
end;

procedure TAndroidBarcodeScanner.Scan(AMode: TBarcodeMode;
AHandler: TAndroidBarcodeAnonEvent);
begin
FHandler := AHandler;
Scan([AMode]);
end;

procedure TAndroidBarcodeScanner.CallScan(AScanCmd: string);
var
intent: JIntent;
begin
if assigned(FClipService) then
begin
FOldClipboard := FClipService.GetClipboard;
FMonitorClipboard := True;
FClipService.SetClipboard(ClipboardCanary);
intent := tjintent.Create;
intent.setAction(stringtojstring('com.google.zxing.client.android.SCAN'));
intent.putExtra(tjintent.JavaClass.EXTRA_TEXT, stringtojstring(AScanCmd));
sharedactivity.startActivityForResult(intent, 0);
end;
end;

procedure TAndroidBarcodeScanner.GetBarcodeValue;
var
value: String;
begin
FMonitorClipboard := false;

if ( FClipService.GetClipboard.ToString <> ClipboardCanary ) then
begin
value := FClipService.GetClipboard.ToString;
if assigned(FHandler) then
FHandler(value)
else if assigned(FOnBarcode) then
FOnBarcode(Self, FClipService.GetClipboard.ToString);
FHandler := nil;
end;
FClipService.SetClipboard(FOldClipboard);
end;

function TAndroidBarcodeScanner.GetModeString(AModes: TBarcodeModes): string;
var
mode: TBarcodeMode;
begin
Result := '';

for mode in AModes do
begin
Result := Result + ',' + BarcodeModes[mode];
end;

Result := StringReplace(Result, ',', '"SCAN_MODE","', []) + '"';

end;

end.
Marcelo Soares

Posts: 1
Registered: 10/18/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2016 4:20 PM   in response to: Pedro Alegria in response to: Pedro Alegria
How utilize?
Adriano Santos

Posts: 55
Registered: 5/17/07
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 4, 2014 8:00 AM   in response to: martin moore in response to: martin moore
http://blogs.embarcadero.com/fernandorizzato/index.php/2013/06/29/barcode-reader-with-delphi-xe4-ios-app/


martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

--
Embarcadero MVP - Brazil
http://www.tdevrocks.com.br
Soumitra Bhatta...

Posts: 1
Registered: 12/20/09
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 12, 2014 7:25 PM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

Here's one you can also try : TTMSFMXZBarReader
http://www.tmssoftware.com/site/freetools.asp
Sebastian Kozub

Posts: 2
Registered: 1/2/14
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 25, 2014 7:09 AM   in response to: Soumitra Bhatta... in response to: Soumitra Bhatta...
I'm looking for tutorial that help me to use the solutions (JAVA) I pasted below in Delphi XE5 for Android...
Now I have application that use ZXing with standard settings (landscape), but I'd like to have portrait screen orientation when scanning:

http://stackoverflow.com/questions/15589379/customized-camera-view-rotation-in-zxing-for-qr-code

http://stackoverflow.com/questions/10216943/android-zxing-change-orientation-to-portrait

The solution looks nice but I don't know how to use it with Delphi
Brent Michaelson

Posts: 1
Registered: 6/27/14
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2014 11:59 PM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

I'm using this barcode reader , good enough for me. :)
loveimage ee

Posts: 1
Registered: 6/2/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2014 1:34 AM   in response to: Brent Michaelson in response to: Brent Michaelson
hi, thanks for sharing your barcode reader application in .net . it is very important for us to find a barcode scanner that is useful.


also check C# barcode generator

Edited by: loveimage ee on Jun 3, 2014 1:35 AM

arron lee

Posts: 6
Registered: 5/28/13
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2014 9:15 PM   in response to: loveimage ee in response to: loveimage ee
Hi, loveimage.
As for me, I am testing the related .net barcode scanner these days. Do you have any ideas about it? Or any good suggestion? I am totally a green hand on barcode scanning field. Any suggestion will be appreciated. Thanks in advance.

Best regards,
Arron

gdfgfd gfdgfdg

Posts: 1
Registered: 8/3/14
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2014 12:43 AM   in response to: arron lee in response to: arron lee
Don't worry about it. I've done this before, and you might simply refer to these two guide below, and this should be no problem: barcode reader for .net components, read barcode in java
E Spelt

Posts: 24
Registered: 12/26/09
Re: Barcode reader for iOS AND Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 23, 2016 2:31 AM   in response to: martin moore in response to: martin moore
martin moore wrote:
Hi, I've foolishly agreed to produce a barcode reader App., but can't find a component/library for Android. I can't believe there isn't one (kind of surprised XE5 doen't include one!).

Can anyone point me in the right direction please.

Thanks.

QRCode, Code128, ITF, Code93 and some in the making:
https://github.com/Spelt/ZXing.Delphi
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02