Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)


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


Permlink Replies: 37 - Last Post: May 28, 2015 11:03 AM Last Post By: Markus Humm
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2015 6:57 AM
Hello,

I'm looking for success stories about Delphi XE7 and android scanning devices.
I plan to develop an barcode reader application, connected to our ERP.

I've have several choices:
- Windows 8 Pro devices with back camera
- Android Tablet with front camera
- Android PDA with scanner

I guess that the Android PDA with scanner solution is the best one. Can Delphi XE7 be used for such purpose ? There is a few messages on this forum where people are complaining about Android and scanner issues....

Does it makes sense to use a back camera to scan barcodes ? Does Delphi have scanning recognizing software on Win/Android platform ?

Looking forward for your answers

Regards,

Stéphane WIERZBICKI
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2015 9:42 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Am 28.01.2015 um 15:57 schrieb Stephane Wierzbicki:
Hello,

I'm looking for success stories about Delphi XE7 and android scanning devices.
I plan to develop an barcode reader application, connected to our ERP.

I've have several choices:
- Windows 8 Pro devices with back camera
- Android Tablet with front camera
- Android PDA with scanner

I guess that the Android PDA with scanner solution is the best one. Can Delphi XE7 be used for such purpose ? There is a few messages on this forum where people are complaining about Android and scanner issues....

Does it makes sense to use a back camera to scan barcodes ? Does Delphi have scanning recognizing software on Win/Android platform ?

Looking forward for your answers

Regards,

Stéphane WIERZBICKI

Hello,

in Delphi no recognition software is being integrated. But I guess on
ANdroid certain java based scanning engines should be useable from XE7
as XE7 made it a bit easier to include custom jars into a Delphi project.

Greetings

Markus
cathy ben

Posts: 10
Registered: 12/21/14
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2015 6:58 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 28.01.2015 um 15:57 schrieb Stephane Wierzbicki:
Hello,

I'm looking for success stories about Delphi XE7 and android scanning devices.
I plan to develop an barcode reader application, connected to our ERP.

I've have several choices:
- Windows 8 Pro devices with back camera
- Android Tablet with front camera
- Android PDA with scanner

I guess that the Android PDA with scanner solution is the best one. Can Delphi XE7 be used for such purpose ? There is a few messages on this forum where people are complaining about Android and scanner issues....

Does it makes sense to use a back camera to scan barcodes ? Does Delphi have scanning recognizing software on Win/Android platform ?

Looking forward for your answers

Regards,

Stéphane WIERZBICKI

Hello,

in Delphi no recognition software is being integrated. But I guess on
ANdroid certain java based scanning engines should be useable from XE7
as XE7 made it a bit easier to include custom jars into a Delphi project.

Greetings

Markus

Does XE7 provide interface for integrating bar code scanner library? I hope adding barcode scanner with some codes can be achieved.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 28, 2015 11:03 AM   in response to: cathy ben in response to: cathy ben
Am 28.05.2015 um 03:58 schrieb cathy ben:
Markus Humm wrote:
Am 28.01.2015 um 15:57 schrieb Stephane Wierzbicki:
Hello,

I'm looking for success stories about Delphi XE7 and android scanning devices.
I plan to develop an barcode reader application, connected to our ERP.

I've have several choices:
- Windows 8 Pro devices with back camera
- Android Tablet with front camera
- Android PDA with scanner

I guess that the Android PDA with scanner solution is the best one. Can Delphi XE7 be used for such purpose ? There is a few messages on this forum where people are complaining about Android and scanner issues....

Does it makes sense to use a back camera to scan barcodes ? Does Delphi have scanning recognizing software on Win/Android platform ?

Looking forward for your answers

Regards,

Stéphane WIERZBICKI

Hello,

in Delphi no recognition software is being integrated. But I guess on
ANdroid certain java based scanning engines should be useable from XE7
as XE7 made it a bit easier to include custom jars into a Delphi project.

Greetings

Markus

Does XE7 provide interface for integrating bar code scanner library? I hope adding barcode scanner with some codes can be achieved.

Hello,

I'm no expert in barcode scanners, even if I used one now and then on
Windows. But that was set up in such a way that it would simply enter
the read information like it had been typed in via keyboard.

Greetings

Markus
Gurkan Karagoz

Posts: 32
Registered: 1/22/14
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2015 4:01 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
http://www.winsoft.sk/fobr.htm
I used Winsoft's barcode recognition component for a project. You may want to try.

Gurkan


Stephane Wierzbicki wrote:
Hello,

I'm looking for success stories about Delphi XE7 and android scanning devices.
I plan to develop an barcode reader application, connected to our ERP.

I've have several choices:
- Windows 8 Pro devices with back camera
- Android Tablet with front camera
- Android PDA with scanner

I guess that the Android PDA with scanner solution is the best one. Can Delphi XE7 be used for such purpose ? There is a few messages on this forum where people are complaining about Android and scanner issues....

Does it makes sense to use a back camera to scan barcodes ? Does Delphi have scanning recognizing software on Win/Android platform ?

Looking forward for your answers

Regards,

Stéphane WIERZBICKI
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 30, 2015 2:02 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Thank you for your replies, but I'm afraid to see that nobody replied about Android with laser barcode scanners.
Does Firemonkey works well on these devices ?
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 30, 2015 7:05 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Does Firemonkey works well on these devices ?
I do not think the question is about Firemonkey on barcode scanning devices. I do not see a special reason why it will not work.
The real problem is interacting with barcode API's from Delphi through JNI bridge.

That being said, my app compiled with XE5 is working well with Honeywell API's.
I moved the project to XE7 and made the changes. It compiles but it is not yet tested on Honeywell devices. Only on normal smartphones using ZXing app.

Best regards,
Cristian Peta

Edited by: Cristian Peta on Jan 30, 2015 5:08 PM
"through" not "trough"
Alfonso Presa

Posts: 19
Registered: 3/21/09
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 9, 2015 12:17 PM   in response to: Cristian Peța in response to: Cristian Peța
I try to use barcdode scanning device with Delphi (Honeywell, Motorla BarcodeScanner, etc) too.

Delphi DON'T work BY DEFAULT, with this devices.

This devices send to edit box a text scaned code.

But, Delphi's edit box are not standard Android edit box. Firemonkey emulates this controls, but this emulation don't work full.

I only scanned with Delphi, by launch intent with app BarcodeScanner.

Alfonso


Cristian Peta wrote:
Does Firemonkey works well on these devices ?
I do not think the question is about Firemonkey on barcode scanning devices. I do not see a special reason why it will not work.
The real problem is interacting with barcode API's from Delphi through JNI bridge.

That being said, my app compiled with XE5 is working well with Honeywell API's.
I moved the project to XE7 and made the changes. It compiles but it is not yet tested on Honeywell devices. Only on normal smartphones using ZXing app.

Best regards,
Cristian Peta

Edited by: Cristian Peta on Jan 30, 2015 5:08 PM
"through" not "trough"
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 10, 2015 12:37 AM   in response to: Alfonso Presa in response to: Alfonso Presa
Alfonso Presa wrote:
But, Delphi's edit box are not standard Android edit box. Firemonkey emulates this controls, but this emulation don't work full.
Maybe in XE8 TEdit.ControlType=Platform will be supported also for Android.
In the meantime you can use D.P.F. native components or try to use scanner APIs.

Best regards,
Cristian Peta

Edited by: Cristian Peta on Feb 10, 2015 10:38 AM
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2015 10:57 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Alfonso Presa wrote:
But, Delphi's edit box are not standard Android edit box. Firemonkey emulates this controls, but this emulation don't work full.
Maybe in XE8 TEdit.ControlType=Platform will be supported also for Android.
In the meantime you can use D.P.F. native components or try to use scanner APIs.

Best regards,
Cristian Peta

Edited by: Cristian Peta on Feb 10, 2015 10:38 AM

Hello Cristian,

I've tried D.P.F. but Edit controls are not correctly created as designtime width isn't taken into account.
Now how can I use the scanner API ? Is there any exemple out here witth an Honeywell Black Dolphin device ?
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 17, 2015 9:25 PM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
Now how can I use the scanner API ? Is there any exemple out here witth an Honeywell Black Dolphin device ?
The java code is now easy to add to the project in XE7. You can find it here:
https://forums.embarcadero.com/message.jspa?messageID=661827
And you need to modify Android manifest template to start NativeActivitySubclass and not standard FMXNativeActivity.
One drawback with this method is that for now in XE7 you can not debug if you start with subclassed native activity. There is a QC about this created by Brian Long.

And here you can see how to use special keys like Scan and the two keys on the side of the device.
https://forums.embarcadero.com/thread.jspa?threadID=106139&tstart=120

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 18, 2015 12:42 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Now how can I use the scanner API ? Is there any exemple out here witth an Honeywell Black Dolphin device ?
The java code is now easy to add to the project in XE7. You can find it here:
https://forums.embarcadero.com/message.jspa?messageID=661827
And you need to modify Android manifest template to start NativeActivitySubclass and not standard FMXNativeActivity.
One drawback with this method is that for now in XE7 you can not debug if you start with subclassed native activity. There is a QC about this created by Brian Long.

And here you can see how to use special keys like Scan and the two keys on the side of the device.
https://forums.embarcadero.com/thread.jspa?threadID=106139&tstart=120

Best regards,
Cristian Peta

Thank you Peta, I will check both links.
There is still extra work to be done :D ...
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 18, 2015 6:14 AM   in response to: Cristian Peța in response to: Cristian Peța
Dear Cristian,

Can I get some little help ? To be honest with you, I don't know from where to start as I'm a total beginner on android and Java too !
I need to control my Honeywell Dolphin 70e Black barcode scanner.

Here is what I've done so far :

- Getting the SDK
I have download different Honeywell SDK files :
- Honeywell_CommonES_Android_SDK_2.39.2314_For_Windows
- Honeywell_SDK_Windows_Android_Addon_2.19

Both of these files does have an Honeywell.jar library. I've taken the biggest one (former file).

- Creating the JNI bridge
I did use Java2OP tool to generate the Androidapi.JNI.Honeywell unit. Unit was correctly generated but I've got an error about Function GetBarcodeData. This function was declared twice (once spelled GetBarcodeData and once spelled getBarcodeData). I did removed the first declaration (with the capitalized G letter).

- Add the SDK to our Delphi project library
I did add the Honeywell.jar library

This is so far where am I. The next step is how to consume the Honeywell library !

Thank you in advance
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2015 3:21 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
- Creating the JNI bridge
I did use Java2OP tool to generate the Androidapi.JNI.Honeywell unit. Unit was correctly generated but I've got an error about Function GetBarcodeData. This function was declared twice (once spelled GetBarcodeData and once spelled getBarcodeData). I did removed the first declaration (with the capitalized G letter).
You do not need this if you use my example.

- Add the SDK to our Delphi project library
I did add the Honeywell.jar library
I have a java code that I compiled and added also.
Here is the batch code to do this
set ANDROID="C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\adt-bundle-windows-x86-20131030\sdk"
set ANDROID_PLATFORM=%ANDROID%\platforms\android-19
set DX_LIB=%ANDROID%\build-tools\android-4.4\lib
set EMBO_LIB="C:\Program Files (x86)\Embarcadero\Studio\15.0\lib\android\debug"
 
set PROJ_DIR=%CD%
set VERBOSE=0
 
echo.
echo Compiling the Java source files
echo.
mkdir output\classes 2> nul
if x%VERBOSE% == x1 SET VERBOSE_FLAG=-verbose
javac %VERBOSE_FLAG% -source 1.6 -target 1.6 -Xlint:deprecation -cp %ANDROID_PLATFORM%\android.jar;%EMBO_LIB%\fmx.jar;libs\honeywell.jar -d output\classes com\winarhi\nativeactivitysubclass\NativeActivitySubclass.java
 
echo.
echo Creating jar containing the new classes
echo.
mkdir output\jar 2> nul
if x%VERBOSE% == x1 SET VERBOSE_FLAG=v
jar c%VERBOSE_FLAG%f output\jar\NativeActivitySubclass.jar -C output\classes com


This is so far where am I. The next step is how to consume the Honeywell library !
Read and try to understand my example.
Honeywell API is used from java code. Linking this java code to Delphi is done with JNativeActivitySubclass interface and RegisterDelphiNativeMethods initialization procedure.

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2015 7:32 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Here is the batch code to do this

Thank you. I was able to compile the .jar file. I've added this file and the Honeywell.jar file to my project library.
My sample project is now compiling and running under the device

Read and try to understand my example.
Honeywell API is used from java code. Linking this java code to Delphi is done with JNativeActivitySubclass interface and RegisterDelphiNativeMethods initialization procedure.

As I understand, your java code is creating an Decoder object and settings scan and scanfaillure events.
RegisterDelphiNativeMethods then bridge java events with Delphi events.

I've noticed that scanner key (special keys 87) doesn't activate the scanner (regardless scanwedge is enabled or not).
Is there something more to do ?

Thank you for your help

Edited by: Stephane Wierzbicki on Feb 19, 2015 5:20 PM
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2015 11:53 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
As I understand, your java code is creating an Decoder object and settings scan and scanfaillure events.
RegisterDelphiNativeMethods then bridge java events with Delphi events.
You will create decoder object from Delphi calling WA_CreateDecodeManager. Then you can call WA_DoScan to start scanning.
I've noticed that scanner key (special keys 87) doesn't activate the scanner (regardless scanwedge is enabled or not).
Is there something more to do ?
You need to hach FMX function onInputEvent as in the second link I posted. You will receive keys in MyHandleAndroidKeyEvent. Special keys will come with (vkKeyCode = 0) and (KeyKind = TKeyKind.kkUnknown) .
Then you will call WA_DoScan. I will look tomorrow in office but I remember I decoupled this call with a TTimer. Maybe you can use TTask also.

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 12:24 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
As I understand, your java code is creating an Decoder object and settings scan and scanfaillure events.
RegisterDelphiNativeMethods then bridge java events with Delphi events.
You will create decoder object from Delphi calling WA_CreateDecodeManager. Then you can call WA_DoScan to start scanning.
How do I create this object from Delphi ?

I've noticed that scanner key (special keys 87) doesn't activate the scanner (regardless scanwedge is enabled or not).
Is there something more to do ?
You need to hach FMX function onInputEvent as in the second link I posted. You will receive keys in MyHandleAndroidKeyEvent. Special keys will come with (vkKeyCode = 0) and (KeyKind = TKeyKind.kkUnknown) .
Then you will call WA_DoScan.
This is already done thanks to your previous example.

I will look tomorrow in office but I remember I decoupled this call with a TTimer. Maybe you can use TTask also.
That's really fine ! Thank you

Best regards,

Stéphane WIERZBICKI
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 1:49 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
Cristian Peta wrote:
Stephane Wierzbicki wrote:
As I understand, your java code is creating an Decoder object and settings scan and scanfaillure events.
RegisterDelphiNativeMethods then bridge java events with Delphi events.
You will create decoder object from Delphi calling WA_CreateDecodeManager. Then you can call WA_DoScan to start scanning.
How do I create this object from Delphi ?
TJNativeActivitySubclass.Wrap(PANativeActivity(System.DelphiActivity)^.clazz).WA_CreateDecodeManager;

And same for WA_DoScan and WA_DestroyDecodeManager
I will look tomorrow in office but I remember I decoupled this call with a TTimer. Maybe you can use TTask also.
That's really fine ! Thank you
I called directly WA_DoScan in MyHandleAndroidKeyEvent.
But I have decoupled processing of received barcode with TTimer because onBarCodeCompleteThreadSwitcher is called from an other thread. You can also use TThread.Queue.

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 4:54 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Cristian Peta wrote:
Stephane Wierzbicki wrote:
As I understand, your java code is creating an Decoder object and settings scan and scanfaillure events.
RegisterDelphiNativeMethods then bridge java events with Delphi events.
You will create decoder object from Delphi calling WA_CreateDecodeManager. Then you can call WA_DoScan to start scanning.
How do I create this object from Delphi ?
TJNativeActivitySubclass.Wrap(PANativeActivity(System.DelphiActivity)^.clazz).WA_CreateDecodeManager;

And same for WA_DoScan and WA_DestroyDecodeManager
I will look tomorrow in office but I remember I decoupled this call with a TTimer. Maybe you can use TTask also.
That's really fine ! Thank you
I called directly WA_DoScan in MyHandleAndroidKeyEvent.
But I have decoupled processing of received barcode with TTimer because onBarCodeCompleteThreadSwitcher is called from an other thread. You can also use TThread.Queue.

I can access scanner now :D

You will certainly know this : how can I add QRCode scanning capacity to the scanner ? And how to I had "beep" sound ?

Anyway thank you sooo much !
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 19, 2015 12:05 PM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Also I suppose you have modified Andriod manifest template to start NativeActivitySubclass. Without this you can not use JNativeActivitySubclass.

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 12:46 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Also I suppose you have modified Andriod manifest template to start NativeActivitySubclass. Without this you can not use JNativeActivitySubclass.

Oops, didn't do it !
I've just tried to modify it but my app crashed :

<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="%package%"
android:versionCode="%versionCode%"
android:versionName="%versionName%">

<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
<%uses-permission%>
<application android:persistent="%persistent%"
android:restoreAnyVersion="%restoreAnyVersion%"
android:label="%label%"
android:installLocation="%installLocation%"
android:debuggable="%debuggable%"
android:largeHeap="%largeHeap%"
android:icon="%icon%"
android:theme="%theme%"
android:hardwareAccelerated="%hardwareAccelerated%">
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<!-- <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" -->
<activity android:name="com.winarhi.nativeactivitysubclass"
android:label="%activityLabel%"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTask">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="%libNameValue%" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<%activity%>
<receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
<%receivers%>
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->

Edited by: Stephane Wierzbicki on Feb 20, 2015 9:50 AM
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 1:51 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
Cristian Peta wrote:
Also I suppose you have modified Andriod manifest template to start NativeActivitySubclass. Without this you can not use JNativeActivitySubclass.

Oops, didn't do it !
I've just tried to modify it but my app crashed :
You need to specify also the activity class (NativeActivitySubclass):
<activity android:name="com.winarhi.nativeactivitysubclass.NativeActivitySubclass"

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 4:48 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Cristian Peta wrote:
Also I suppose you have modified Andriod manifest template to start NativeActivitySubclass. Without this you can not use JNativeActivitySubclass.

Oops, didn't do it !
I've just tried to modify it but my app crashed :
You need to specify also the activity class (NativeActivitySubclass):
<activity android:name="com.winarhi.nativeactivitysubclass.NativeActivitySubclass"

Best regards,
Cristian Peta

Done and working. There is just one drawback since : I need to manualy launch my app !
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 5:23 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
Done and working. There is just one drawback since : I need to manualy launch my app !
This is the reason you ca not debug also.
You can vote for this QC:
http://qc.embarcadero.com/wc/qcmain.aspx?d=118450

Best regards,
Cristian Peta
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2015 7:23 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Done and working. There is just one drawback since : I need to manualy launch my app !
This is the reason you ca not debug also.
You can vote for this QC:
http://qc.embarcadero.com/wc/qcmain.aspx?d=118450

Best regards,
Cristian Peta

Ok. Will vote on this...

I've modified the java ScanResultHandler to handle QR Code :

private Handler ScanResultHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case DecodeManager.MESSAGE_DECODER_COMPLETE:
WA_mScanAccount++;
DecodeResult decodeResult = (DecodeResult) msg.obj;

//byte codeid = decodeResult.codeId;
//byte aimid = decodeResult.aimId;
//int iLength = decodeResult.length;

strDecodeResult = decodeResult.barcodeData;
onBarCodeCompleteNative(strDecodeResult);
break;

case DecodeManager.MESSAGE_DECODER_FAIL: {
strDecodeResult = "";
onBarCodeFailNative();
}
break;
case DecodeManager.MESSAGE_DECODER_READY:
{
try {
//mDecodeManager.disableSymbology(CommonDefine.SymbologyID.SYM_ALL);
SymbologyConfigCodeQRCode QRCode = new SymbologyConfigCodeQRCode();
QRCode.enableSymbology(true);
SymbologyConfigs symconfig = new SymbologyConfigs();
symconfig.addSymbologyConfig(QRCode);
mDecodeManager.setSymbologyConfigs(symconfig);
mDecodeManager.enableSymbology(CommonDefine.SymbologyID.SYM_QR);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
default:
super.handleMessage(msg);
break;
}
}
};

Edited by: Stephane Wierzbicki on Feb 24, 2015 12:00 PM
DAVID PEREZ MORA

Posts: 4
Registered: 12/15/05
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 3:43 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Stephane Wierzbicki wrote:
Cristian Peta wrote:
Stephane Wierzbicki wrote:
Done and working. There is just one drawback since : I need to manualy launch my app !
This is the reason you ca not debug also.
You can vote for this QC:
http://qc.embarcadero.com/wc/qcmain.aspx?d=118450

Best regards,
Cristian Peta

Ok. Will vote on this...

I've modified the java ScanResultHandler to handle QR Code :

private Handler ScanResultHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case DecodeManager.MESSAGE_DECODER_COMPLETE:
WA_mScanAccount++;
DecodeResult decodeResult = (DecodeResult) msg.obj;

//byte codeid = decodeResult.codeId;
//byte aimid = decodeResult.aimId;
//int iLength = decodeResult.length;

strDecodeResult = decodeResult.barcodeData;
onBarCodeCompleteNative(strDecodeResult);
break;

case DecodeManager.MESSAGE_DECODER_FAIL: {
strDecodeResult = "";
onBarCodeFailNative();
}
break;
case DecodeManager.MESSAGE_DECODER_READY:
{
try {
//mDecodeManager.disableSymbology(CommonDefine.SymbologyID.SYM_ALL);
SymbologyConfigCodeQRCode QRCode = new SymbologyConfigCodeQRCode();
QRCode.enableSymbology(true);
SymbologyConfigs symconfig = new SymbologyConfigs();
symconfig.addSymbologyConfig(QRCode);
mDecodeManager.setSymbologyConfigs(symconfig);
mDecodeManager.enableSymbology(CommonDefine.SymbologyID.SYM_QR);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
default:
super.handleMessage(msg);
break;
}
}
};

Edited by: Stephane Wierzbicki on Feb 24, 2015 12:00 PM

How did you manage to have a beep after the scanning?
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 3:50 AM   in response to: DAVID PEREZ MORA in response to: DAVID PEREZ MORA
JOSE GINE MASDEU wrote:
How did you manage to have a beep after the scanning?
I used TMediaPlayer with mp3 but if you want you can do it from Java like SDK examples.
My beep mp3 file is 775 bytes.

Best regards,
Cristian Peta
DAVID PEREZ MORA

Posts: 4
Registered: 12/15/05
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 4:07 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
JOSE GINE MASDEU wrote:
How did you manage to have a beep after the scanning?
I used TMediaPlayer with mp3 but if you want you can do it from Java like SDK examples.
My beep mp3 file is 775 bytes.

Best regards,
Cristian Peta

Thank you! I was thinking about TMediaPlayer too but I was wondering if it was any other way to do it.. Let me thank you for all the info I got from all these posts from you to finally scan with a Honeywell scanner successfully.. Great job!
DAVID PEREZ MORA

Posts: 4
Registered: 12/15/05
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 10:25 AM   in response to: Cristian Peța in response to: Cristian Peța
Cristian Peta wrote:
JOSE GINE MASDEU wrote:
How did you manage to have a beep after the scanning?
I used TMediaPlayer with mp3 but if you want you can do it from Java like SDK examples.
My beep mp3 file is 775 bytes.

Best regards,
Cristian Peta

if you don't mind, just one more question... how did you do to wait for the result of the scanning? what approach did you use? thank you in advance and sorry for bothering you so much
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 12:32 PM   in response to: DAVID PEREZ MORA in response to: DAVID PEREZ MORA
JOSE GINE MASDEU wrote:
if you don't mind, just one more question... how did you do to wait for the result of the scanning? what approach did you use? thank you in advance and sorry for bothering you so much
I do not understand what exactly you meant with waiting. It is an event.
I receive the barcode in onBarCodeCompleteNative from Java.

Best regards,
Cristian Peta
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 12:42 PM   in response to: DAVID PEREZ MORA in response to: DAVID PEREZ MORA
JOSE GINE MASDEU wrote:
if you don't mind, just one more question... how did you do to wait for the result of the scanning? what approach did you use? thank you in advance and sorry for bothering you so much
I do not understand what exactly you meant with waiting. It is an event.
I receive the barcode in onBarCodeCompleteNative from Java.

Best regards,
Cristian Peta
DAVID PEREZ MORA

Posts: 4
Registered: 12/15/05
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2015 8:23 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
This thread is really interesting! I have a Honeywell Dolphin 70e Black and I was wondering if there's an easiest way to access to barcode scanning like an Intent call similar to the one that's done with the Zxing library using the camera of an Android smartphone (with the Honeywell software installed, it seems like an option to me). Is that possible? I am very new to all this stuff and I would appreciate any help. Thank you very much in advance.
Cristian Peța

Posts: 157
Registered: 8/7/06
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2015 3:46 AM   in response to: DAVID PEREZ MORA in response to: DAVID PEREZ MORA
JOSE GINE MASDEU wrote:
This thread is really interesting! I have a Honeywell Dolphin 70e Black and I was wondering if there's an easiest way to access to barcode scanning like an Intent call similar to the one that's done with the Zxing library using the camera of an Android smartphone (with the Honeywell software installed, it seems like an option to me). Is that possible? I am very new to all this stuff and I would appreciate any help. Thank you very much in advance.
From what I know you can use Intent to start the scanner but for Motorola devices.

Best regards,
Cristian Peta
Francisco Cholb...

Posts: 3
Registered: 3/22/08
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 26, 2015 12:52 PM   in response to: DAVID PEREZ MORA in response to: DAVID PEREZ MORA
JOSE GINE MASDEU wrote:
This thread is really interesting! I have a Honeywell Dolphin 70e Black and I was wondering if there's an easiest way to access to barcode scanning like an Intent call similar to the one that's done with the Zxing library using the camera of an Android smartphone (with the Honeywell software installed, it seems like an option to me). Is that possible? I am very new to all this stuff and I would appreciate any help. Thank you very much in advance.

Buenas Jose,

I can help you with two classes that we have just develop after several days fighting with Java Bridge, Intents, Activities, and a lot of stuff readed from this forum and others. It is a hard and ugly work that I don't wish to nobody. For this reason and seeing that anybody want to share a complete solution for the problem, I want to share this two classes that it have been tested with Honeywell Dolphin 70e Black and Delphi XE7 without any problem. We know that the use of "Intent" concept and "TMessageManager" is only compatible from XE6, so don't try to use this solution in XE5:

- THandheld : It catch Down/Up especial keys from Honeywell Dolphin 70e and surely other handheld hardware.
- THoneywell : It uses THandheld class as parent. It catches especial keys and process them as a Decode actions. It implements an Event to catch the results when a Decode Complete message arrive with the result.

unit ClasseHandheld;
 
interface
 
uses
  System.SysUtils,
  FMX.Types,
  FMX.Dialogs,
  FMX.Platform.Android,
  Androidapi.Appglue,
  Androidapi.Input;
 
type
  TOnKeyUpHandheld = procedure (Keycode: Word) of object;
  TOnKeyDownHandheld = procedure (Keycode: Word) of object;
 
  THandheld = class(TObject)
  private
    { Private declarations }
    function MyHandleAndroidKeyEvent(AEvent: PAInputEvent): Int32;
  public
    { Public declarations }
    OnKeyUp: TOnKeyUpHandheld;
    OnKeyDown: TOnKeyDownHandheld;
 
    constructor Create;
    destructor Destroy; override;
  end;
 
var
  LastInstance: THandheld;
  OldHandleAndroidInputEvent: function(App: PAndroid_app; Event: PAInputEvent): Int32; cdecl;
 
implementation
 
function MyHandleAndroidInputEvent(var App: PAndroid_app; AEvent: PAInputEvent): Int32; cdecl;
var
  EventType: Int64;
begin
  Result := OldHandleAndroidInputEvent(App, AEvent);
 
  EventType := AInputEvent_getType(AEvent);
  if EventType = AINPUT_EVENT_TYPE_KEY then
    if Assigned(LastInstance) then
      LastInstance.MyHandleAndroidKeyEvent(AEvent); // Keyboard input
end;
 
constructor THandheld.Create;
begin
  inherited;
 
  LastInstance:=Self;
  OnKeyUp:=nil;
  OnKeyDown:=nil;
 
  OldHandleAndroidInputEvent := GetAndroidApp^.onInputEvent;
  GetAndroidApp^.onInputEvent := @MyHandleAndroidInputEvent;
end;
 
destructor THandheld.Destroy;
begin
  GetAndroidApp^.onInputEvent := OldHandleAndroidInputEvent;
  LastInstance := nil;
  inherited;
end;
 
function THandheld.MyHandleAndroidKeyEvent(AEvent: PAInputEvent): Int32;
var
  KeyCode, vkKeyCode, ScanCode: Word;
  KeyKind: TKeyKind;
begin
  Result := 0;
 
  KeyCode := AKeyEvent_getKeyCode(AEvent);
  vkKeyCode := PlatformKeyToVirtualKey(KeyCode, KeyKind);
  //Read special (unknown keys)
// OJO: TKeyKind.kkUnknown  deprecated usar TKeyKind.Unknown
//  if (vkKeyCode = 0) and (KeyKind = TKeyKind.kkUnknown) then
  if (vkKeyCode = 0) and (KeyKind = TKeyKind.Unknown) then
  begin
    case AKeyEvent_getAction(AEvent) of
      AKEY_EVENT_ACTION_DOWN:
        begin
          ScanCode := AKeyEvent_getScanCode(AEvent);
          if Assigned(OnKeyDown) then OnKeyDown(Scancode);
        end;
      AKEY_EVENT_ACTION_UP:
        begin
          ScanCode := AKeyEvent_getScanCode(AEvent);
          if Assigned(OnKeyUp) then OnKeyUp(Scancode);
        end;
    end;
  end;
end;
 
initialization
  LastInstance:=nil;
 
end.


unit ClasseHoneywell;
 
interface
 
uses
  ClasseHandheld,
  System.Messaging,
  FMX.Dialogs,
  System.SysUtils,
  Androidapi.Helpers,
  Androidapi.Jni.Interfaces,
  Androidapi.JNI.GraphicsContentViewText;
 
const
  LEFT_UP_KEY = 87;
  RIGHT_UP_KEY = 88;
  CENTRAL_KEY = 148;
 
  ERR_CANT_DISP_BC_SCANNER = -1;                  //Error: Cannot display Barcode scanner
 
type
  TOnScannerCompleted = procedure (ScanFormat, ScanContent: string) of object;
  TOnScannerError = procedure (ResultCode: Integer) of object;
 
  THoneywell = class(THandheld)
  private
    { Private declarations }
    Scanmode: Integer;
 
    procedure LaunchScanner;
    function LaunchActivityForResult(const Intent: JIntent): Boolean;
 
    var FMessageSubscriptionID: Integer;
    procedure HandleActivityMessage(const Sender: TObject; const M: TMessage);
    function OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean;
 
    procedure ProcOnKeyDown(Keycode: Word);
    procedure DoScan;
 
  public
    { Public declarations }
    OnScannerCompleted: TOnScannerCompleted;
    OnScannerError: TOnScannerError;
    constructor Create;
    destructor Destroy; override;
  end;
 
implementation
 
constructor THoneywell.Create;
begin
  inherited ;
 
  Scanmode:=TJScanIntent.JavaClass.SCAN_MODE_RESULT_AS_URI;
  OnKeyDown := Self.ProcOnKeyDown;
  OnScannerCompleted:=nil;
  OnScannerError:=nil;
end;
 
destructor THoneywell.Destroy;
begin
 
  inherited;
end;
 
procedure THoneywell.ProcOnKeyDown(Keycode: Word);
begin
  if (Keycode = LEFT_UP_KEY) or
     (Keycode = RIGHT_UP_KEY) or
     (Keycode = CENTRAL_KEY) then
  Begin
    DoScan;
  end;
end;
 
procedure THoneywell.DoScan;
begin
  FMessageSubscriptionID := TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, HandleActivityMessage);
 
  LaunchScanner;
end;
 
procedure THoneywell.LaunchScanner;
var
  Intent: JIntent;
begin
  Intent := TJIntent.JavaClass.init(TJScanIntent.JavaClass.SCAN_ACTION);
  Intent.putExtra(StringToJString('SCAN_MODE'), Scanmode);
  if not LaunchActivityForResult(Intent) then
    If Assigned(OnScannerError) Then OnScannerError(ERR_CANT_DISP_BC_SCANNER);
end;
 
function THoneywell.LaunchActivityForResult(const Intent: JIntent): Boolean;
var
  ResolveInfo: JResolveInfo;
begin
  ResolveInfo := SharedActivity.getPackageManager.resolveActivity(Intent, 0);
  Result := ResolveInfo <> nil;
  if Result then
    SharedActivity.startActivityForResult(Intent, Scanmode);
end;
 
procedure THoneywell.HandleActivityMessage(const Sender: TObject; const M: TMessage);
begin
  if M is TMessageResultNotification then
    OnActivityResult(TMessageResultNotification(M).RequestCode, TMessageResultNotification(M).ResultCode, TMessageResultNotification(M).Value);
end;
 
function THoneywell.OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean;
var
  ScanContent, ScanFormat: string;
begin
  Result := False;
 
  TMessageManager.DefaultManager.Unsubscribe(TMessageResultNotification, FMessageSubscriptionID);
  FMessageSubscriptionID := 0;
 
  if RequestCode = Scanmode then
  begin
    if ResultCode = TJScanIntent.JavaClass.SCAN_RESULT_SUCCESSED Then
    begin
      if Assigned(Data) then
      begin
        ScanContent := JStringToString(Data.getStringExtra(TJScanIntent.JavaClass.EXTRA_RESULT_BARCODE_DATA));
        ScanFormat := JStringToString(Data.getStringExtra(TJScanIntent.JavaClass.EXTRA_RESULT_BARCODE_FORMAT));
        If Assigned(OnScannerCompleted) Then OnScannerCompleted(ScanFormat, ScanContent);
      end;
    end
    else if ResultCode = TJScanIntent.JavaClass.SCAN_RESULT_FAILED then
    begin
       If Assigned(OnScannerError) Then OnScannerError(ResultCode);
    end;
    Result := True;
  end;
end;
 
end.


Note: "Androidapi.Jni.Interfaces" unit is a exported unit from Honeywell .JAR library.

Good luck!!

Edited by: Patrick Mira on Mar 26, 2015 1:01 PM

Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2015 1:41 PM   in response to: Francisco Cholb... in response to: Francisco Cholb...
Thank you for sharing this with us :D
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 7, 2015 5:02 AM   in response to: Francisco Cholb... in response to: Francisco Cholb...
Hello Patrick,

Do you know if there is a way to speed up the intent creation.
Users have to wait up to 1 second for getting the scanner to works.

Included Honeywell scanning demo is so snappy !
Francisco Cholb...

Posts: 3
Registered: 3/22/08
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 10, 2015 2:50 AM   in response to: Stéphane WIERZB... in response to: Stéphane WIERZB...
Hi Stephane,

If there is a way I don't know it. The delay effect can be hide a little programming KeyDown event instead KeyUp.

Patrick,

Stephane Wierzbicki wrote:
Hello Patrick,

Do you know if there is a way to speed up the intent creation.
Users have to wait up to 1 second for getting the scanner to works.

Included Honeywell scanning demo is so snappy !
Stéphane WIERZB...

Posts: 58
Registered: 9/3/00
Re: Delphi XE7 and android scanning devices (Motorola,Honeyweel...)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 20, 2015 12:22 PM   in response to: Francisco Cholb... in response to: Francisco Cholb...
Patrick Mira Pedrol wrote:

Hello,

Did you get any result from ScanFormat ?
String remains empty. Do you have any clue why I can't get this value ?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02