public final class AidcManager extends Object
AidcManager
singleton. Once created, the AidcManager
provides a method to create
BarcodeReader
objects.
Begin by calling create(Context, CreatedCallback)
where Context
is the context of the client
application, and AidcManager.CreatedCallback
is an object that
implements the AidcManager.CreatedCallback
interface.
When create(Context, CreatedCallback)
is called the
scanner service is bound to, and the service binding is used to create
the AidcManager
. Once created, the AidcManager
is
passed to the application by calling
AidcManager.CreatedCallback.onCreated(AidcManager)
.
Call createBarcodeReader()
to create a BarcodeReader
object connected to the internal scanner. All interactions with the scanner
will be done through this object.
The following is an example code snippet.
import com.honeywell.aidc.*; public class MainActivity extends Activity { private AidcManager manager; private BarcodeReader reader; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // create the AidcManager providing a Context and an // CreatedCallback implementation. AidcManager.create(this, new AidcManager.CreatedCallback() { @Override public void onCreated(AidcManager aidcManager) { manager = aidcManager; reader = manager.createBarcodeReader(); } } } @Override public void onDestroy() { super.onDestroy(); // make sure that AidcManager isn't null if (reader != null) { // close BarcodeReader to clean up resources. // once closed, the object can no longer be used. reader.close(); } if (manager != null) { // close AidcManager to disconnect from the scanner service. // once closed, the object can no longer be used. manager.close(); } } }
Modifier and Type | Class and Description |
---|---|
static interface |
AidcManager.BarcodeDeviceListener
Used in conjunction with
addBarcodeDeviceListener(BarcodeDeviceListener) . |
static interface |
AidcManager.CreatedCallback
This interface defines a method to notify the application
that the scanner service has successfully been bound to and
that the
AidcManager has been created. |
Modifier and Type | Field and Description |
---|---|
static int |
BARCODE_DEVICE_CONNECTED
Indicates that the Barcode Device is connected
|
static int |
BARCODE_DEVICE_DISCONNECTED
Indicates that the Barcode Device is disconnected
|
Modifier and Type | Method and Description |
---|---|
void |
addBarcodeDeviceListener(AidcManager.BarcodeDeviceListener listener)
Register a callback to be invoked when the list of Bar code Devices changes
|
void |
close()
Disconnect the scanner service.
|
static void |
create(Context context,
AidcManager.CreatedCallback callback)
Bind to the scanner service and create the singleton instance of
AidcManager . |
BarcodeReader |
createBarcodeReader()
This attempts to instantiate a
BarcodeReader . |
BarcodeReader |
createBarcodeReader(String scannerName)
This attempts to instantiate a
BarcodeReader . |
List<BarcodeReaderInfo> |
listBarcodeDevices()
Returns a list of
BarcodeReaderInfo objects. |
List<BarcodeReaderInfo> |
listConnectedBarcodeDevices()
Returns a list of
BarcodeReaderInfo objects. |
void |
removeBarcodeDeviceListener(AidcManager.BarcodeDeviceListener listener)
Unregister a bar code device change callback.
|
public static final int BARCODE_DEVICE_DISCONNECTED
public static final int BARCODE_DEVICE_CONNECTED
public void addBarcodeDeviceListener(AidcManager.BarcodeDeviceListener listener)
Client activities should consider calling this method in onCreate() since event listener registration only needs to happen once time.
listener
- The callback that will runpublic void removeBarcodeDeviceListener(AidcManager.BarcodeDeviceListener listener)
listener
- The callback to unregisterpublic static void create(Context context, AidcManager.CreatedCallback callback)
AidcManager
. Once created, the AidcManager
is passed to
the provided AidcManager.CreatedCallback
in the
AidcManager.CreatedCallback.onCreated(AidcManager)
method. The
application can then use the AidcManager
to create a
BarcodeReader
.context
- Context
used to bind to the scanner
service.callback
- An object that implements the
AidcManager.CreatedCallback
interfacepublic List<BarcodeReaderInfo> listBarcodeDevices()
BarcodeReaderInfo
objects. Each object
represents a bar code device that was installed at some point since the
device was powered on, whose unique name can be used to create a new
BarcodeReader
.
This means that the list may return BarcodeReaderInfo
objects for
bar code devices that are not currently attached to the device. It is
recommended that you use the function
listConnectedBarcodeDevices()
if you are interested
only in bar code devices that are currently connected to the unit.
This function may return null to indicate limited functionality. In this
case, call createBarcodeReader()
when creating a
BarcodeReader object.BarcodeReaderInfo.getName()
,
createBarcodeReader(String)
public List<BarcodeReaderInfo> listConnectedBarcodeDevices()
BarcodeReaderInfo
objects. Each object
represents a bar code device that is currently connected to the device,
whose unique name can be used to create a new BarcodeReader
.
This function may return null to indicate limited functionality. In this
case, call createBarcodeReader()
when creating a
BarcodeReader object.BarcodeReaderInfo.getName()
,
createBarcodeReader(String)
public void close()
public BarcodeReader createBarcodeReader()
BarcodeReader
. If an error occurs,
an exception describing the error will be thrown. The returned
BarcodeReader
object represents a session associated with the
internal scanner.BarcodeReader
holding a session to the internal scannerpublic BarcodeReader createBarcodeReader(String scannerName)
BarcodeReader
. If an error occurs,
an exception describing the error will be thrown. The returned
BarcodeReader
object represents a session associated with the
specified scanner.scannerName
- The scanner to create the BarcodeReader object forBarcodeReader
holding a session to the internal scannerCopyright (c) 2015 Honeywell International Inc. All Rights Reserved.