Socket ScanAPI Reference
5 ScanAPI Helper (available for Java, C# and Objective C)
ScanAPI Helper has been created to facilitate the integration of ScanAPI into an
application.
It is released as source code and therefore can be highly customizable for the need
of your application. Some basic and common features are provided as sample on
how to use ScanAPI.
NOTE: ScanAPI Helper is available for Java, C# and Objective C base code.
ScanAPI Helper maintains a list of commands to send to ScanAPI. Since properties
cannot be sent before the completion of the previous one, it offers an easy way to
queue the commands and provides a callback for each command completion.
A command in this context is either a "Set Property" or a "Get Property".
By example, if an application wants to retrieve the friendly name and the version of
the connected device, it uses ScanAPIHelper to do a "PostGetFriendlyName" and a
"PostGetDeviceVersion" in a row, and for each of these functions, a callback is
passed, so when the Get Friendly Name completes, the callback is called and the
application can refresh the UI with the new friendly name, and it follows the same
logic when Get Device Version completes.
It retries sending the command up to 3 times if the command completion failed in
time out error.
The Java version of ScanAPI Helper creates a timer task to consume asynchronous
ScanObject coming from ScanAPI.
The C# and Objective C version of ScanAPI Helper does not create a timer, but
instead provides a method, DoScanAPIReceive, that has to be called from a timer
function or a thread.
The following paragraph describes the steps required for using ScanAPI Helper.
5.1 Handling the ScanAPI Helper notifications
Since most of the ScanAPI operations are asynchronous, it is very important to setup
a way for handling notifications. ScanAPI Helper provides a
ScanAPIHelperNotification interface or a ScanApiHelperDelegate protocol for
Objective C environment that must be implemented in order to handle the various
notifications correctly.
Here is how Scanner Settings for Android is using this interface:
private
ScanApiHelperNotification
/**
* receive a notification indicating ScanAPI has terminated,
* then send an intent to finish the activity if it is still
© 2013 Socket Mobile, Inc.
_scanApiHelperNotification=new
ScanApiHelperNotification() {
26/152
Need help?
Do you have a question about the ScanAPI and is the answer not in the manual?