Table of Contents
App API
This API provides methods to interact with the app itself
1 2 |
// Asked for the PIN and exits the app if the correct PIN was entered App.exitWithPin(); |
1 2 |
// Exits the app App.exit(); |
Barcode Scanner API
Since version 1.5.0, the app provides a JS interface to interact with the scanner. The interface exposes the follow methods.
1 2 |
// Starts the scanner with it's current settings Scanner.startScan(); |
1 2 |
// Stops the current scan if running Scanner.stopScan(); |
1 2 3 |
// Enables or disables the hardware scan trigger // This setting does not affect the .startScan() function Scanner.setTriggerEnabled(bool enabled); |
NFC API
1 2 |
// Enables or disables the NFC reader Nfc.setEnabled(bool enabled); |
Bluetooth API
Since version 1.8.0, the app provides a JS interface to interact with the Bluetooth module. Since almost all the calls are asynchronous, a callback function is needed to receive the results.
This callback function needs to be provided as a string of the function name. This function will be called with 2 parameters in both a successful and error case. The first parameter is the error. This is set to false if the operation was successful or will contain the error message if an error occurred. The 2nd parameter is a message which is always and can be used to provide feedback on the operation.
1 2 |
// Enables or disables the Bluetooth radio Bluetooth.setEnabled(boolean enabled, String callback) |
1 2 3 4 5 |
// Connects to a nearby device via the mac address. // This devices should be paired in the system first. // Otherwise the pairing notification will be shown // which might not be accessible in kiosk-mode. Bluetooth.connect(String mac, String callback) |
1 2 |
// Sends the data to the connected Bluetooth device Bluetooth.write(String data, String callback) |
1 2 |
// Disconnects from the Bluetooth device Bluetooth.disconnect(String callback) |
1 2 3 4 5 |
// Returns a JSON array with the keys "address" and "name" set // for each paired device // Note: This is returned as a string so youΓÇÖll have to use JSON.parse() // to receive the actual array object Bluetooth.getPairedDevices() |
Intent API
Since version 1.8.0, you can trigger any intent from an action and receive the returned data in a callback.
The example below shows how to use a camera-based Barcode Scanner using this API.
1 2 3 4 5 6 7 8 9 10 |
function onResultCallback(requestCode, rawJson){ if(requestCode != 1234) return; var data = JSON.parse(rawJson); var content = data.SCAN_RESULT; document.form1.scan1.value = content; } function scan(){ Intent.start('com.google.zxing.client.android.SCAN', 1234, 'onResultCallback'); } |