public interface SmartCardReaderDevice extends Device, TimeConstants
The smart card device object is obtained from the POSTerminal
, its' as follows:
SmartCardReaderDevice martCardReaderDevice = (SmartCardReaderDevice) POSTerminal.getInstance().getDevice("cloudpos.device.smartcardreader");Among them, the "cloudpos.device.smartcardreader" string is to identify the smart card device, defined by the specific implementation.
Uses the smart card device object to control the operation of the smart card device.
An app can request permission to access the device, as shown below:
<uses-permission android:name="android.permission.CLOUDPOS_SMARTCARD"/>
Device
FOREVER, IMMEDIATE, MilliSECOND, SECOND
Modifier and Type | Method and Description |
---|---|
void |
listenForCardAbsent(OperationListener listener,
int timeout)
Listens until a card is removed from this terminal.
|
void |
listenForCardPresent(OperationListener listener,
int timeout)
Listens until a card is inserted in this terminal.
|
void |
open(int logicalID)
Opens the device.
|
SmartCardReaderOperationResult |
waitForCardAbsent(int timeout)
This is the synchronous method of the
listenForCardAbsent(OperationListener,int) . |
SmartCardReaderOperationResult |
waitForCardPresent(int timeout)
This is the synchronous method of the
listenForCardPresent(OperationListener,int) . |
cancelRequest, close, getFailCount, getUsageCount, open
void open(int logicalID) throws DeviceException
logicalID
- logical ID of the device to open.DeviceException
- for the standard reasons that are documented in
DeviceException
.void listenForCardPresent(OperationListener listener, int timeout) throws DeviceException
This is an asynchronous method.
handleResult()
will be invoked when at least one card has been detected in the field.
Because this method uses a timeout parameter, the device receiving this request MUST be able to
successfully respond to cancelRequest()
and abort the operation.
In case of a timeout occurring, the operation result will contain code=
ERR_TIMEOUT
, and no information about
card will be available.
timeout
- the maximum scanning time of the method, in milliseconds.listener
- operation listener.DeviceException
- for the standard reasons that are documented in
DeviceException
OperationListener.handleResult(com.cloudpos.OperationResult)
SmartCardReaderOperationResult waitForCardPresent(int timeout) throws DeviceException
listenForCardPresent(OperationListener,int)
.timeout
- the maximum scanning time of the method, in milliseconds.DeviceException
- for the standard reasons that are documented in
DeviceException
void listenForCardAbsent(OperationListener listener, int timeout) throws DeviceException
This is an asynchronous method.
Because this method uses a timeout parameter, the device receiving this request MUST be able to
successfully respond to cancelRequest()
and abort the operation.
In case of a timeout occurring, the operation result will contain code=
ERR_TIMEOUT
, and no information about
card will be available.
listener
- operation listener.timeout
- the maximum wait time of the method, in milliseconds.DeviceException
- for the standard reasons that are documented in
DeviceException
SmartCardReaderOperationResult waitForCardAbsent(int timeout) throws DeviceException
listenForCardAbsent(OperationListener,int)
.timeout
- the maximum wait time of the method, in milliseconds.DeviceException
- for the standard reasons that are documented in
DeviceException