Socket ScanAPI Reference
5.2 Set ScanAPI Helper notification
ScanAPI Helper must be instructed to use your notification handler object and this
can be accomplished by calling the setNotification method (or setDelegate in
Objective C) with the reference to the notification interface implementation.
_scanApiHelper.setNotification(_scanApiHelperNotification);
This is important to use this function prior calling the open function to be sure to
trap all the notifications.
5.3 Open ScanAPI Helper
Once the ScanAPI Helper object has been instantiate by using the new function, it
can then be open using the open() method. The open() method doesn't return
anything but instead the onScanApiInitializeComplete notification will be called
once the ScanAPI initialization process has been completed. A result code indicates
how successful the initialization was.
Example:
5.4 Close ScanAPI Helper
Once the application is done with ScanAPI, it can close it by calling the close method
of the ScanAPIHelper object as shown below:
_scanApiHelper.close();
The close method doesn't return any value, but the notification
onScanApiTerminated will be called when ScanAPI has effectively shutdown.
5.5 Scanner arrival
When a scanner connects to the host, ScanAPI Helper notifies the application using
the onDeviceArrival notification and specifies a result code, and in case of success it
also specifies the device information (friendly name, device type). ScanAPI Helper
keeps the device information object into its devices list. The application can retrieve
this list at any time. In our Scanner Settings SDK sample application for Android
platform, this notification asks the activity to refresh with the new scanner
information or in case of an error, it displays an error message as described below:
/**
* a device is connecting, update the UI accordingly
*/
public void onDeviceArrival(long
© 2013 Socket Mobile, Inc.
_scanApiHelper.open();
result, DeviceInfo newDevice) {
Intent intent=null;
if(SktScanErrors.SKTSUCCESS(result)){
_currentSelectedDevice=newDevice;
intent=new
Intent(NOTIFY_SCANNER_ARRIVAL);
intent.putExtra(EXTRA_DEVICENAME,newDevice.getName());
}
else
{
String text=getString(R.string.error_)+result+
getString(R.string._during_device_arrival_notification);
intent=new
Intent(NOTIFY_ERROR_MESSAGE);
32/152
Need help?
Do you have a question about the ScanAPI and is the answer not in the manual?