Intent intent = new Intent ("nlscan.action.SCANNER_TRIG");
intent.putExtra("SCAN_TIMEOUT", 4);// SCAN_TIMEOUT value: int, 1-9; unit: second
intent.putExtra("SCAN_TYPE ", 2);// SCAN_TYPE: read two barcodes during a scan attempt
mContext.sendBroadcast(intent);
Note: When a scan and decode session is in progress, sending the broadcast above will stop the
ongoing session. When scanning barcode by pressing the Scan key, it is processed at the bottom layer,
thus application does not need to listen for Scan KeyPress event or send the broadcast.
Get Barcode Data
There are three ways to get barcode data:
1. Fill in EditText directly: Output scanned data at the current cursor position in EditText.
2. Simulate keystroke: Output scanned data to keyboard buffer to simulate keyboard input and get the
data at the current cursor position in TextBox.
3. Output via API: Application acquires scanned data by registering a broadcast receiver and listening for
specific broadcast intents.
Broadcast: nlscan.action.SCANNER_RESULT
To get barcode data.
Extra scan result 1 parameter: SCAN_BARCODE1
To get the data of barcode 1.
Type: String
Extra scan result 2 parameter: SCAN_BARCODE2
To get the data of barcode 2.
Type: String
Extra symbology ID number parameter: SCAN_BARCODE_TYPE
Type: int (-1 indicates failure to get symbology ID Number)
To get the ID number of the barcode scanned (Refer to the “Symbology ID Number” table in
Appendix to get the barcode type).
Extra scan state parameter: SCAN_STATE (value: fail or ok)
To get the status of scan operation: Value = fail, operation failed
Value = ok, operation succeeded
Type: String
Example:
Register broadcast receiver: