Connect your Bluetooth barcode scanner to your device using an spp profile, and send the captured barcodes to Blue - Bars, using the RFCOMM protocol. Blue - Bars will notify all the apps that are registered to its events of the captures made.
How does it work ?
Blue - Bars works using an independent service that allows it to work in the background, while the receiving application is displayed at all times on the screen of our smartphone.
The events broadcasted by Blue - Bars, are simple BroadcastReceiver that are broadcasted to any application that subscribes to them. Note that these events will be subject to the execution of Blue - Bars and, therefore, they will stop being emitted once the application is completely closed.
Quick guide
• Open Blue - Bars and turn on your barcode scanner in spp mode.
• Accept the Bluetooth permissions of the application to make it work.
• Select your bluetooth scanner from the list of devices for pairing
• On the next screen press play or autoplay and wait for the connection.
• Start scanning barcodes
BroadcastReceiver
All broadcasts sent by Blue - Bars are displayed on the application screen just as they are broadcasted.
ACTION_BARCODE_SCANNER_CONNECTING - When the application tries to connect to your device.
ACTION_BARCODE_SCANNER_CONNECTED - When the device has been connected.
ACTION_BARCODE_SCANNER_DISCONNECTED - When the device is disconnected.
ACTION_BARCODE_SCANNER_CONNECTION_ERROR - When a connection error occurs or the device is disconnected unexpectedly. This event receives the extra - EXTRA_ERROR_MESSAGE - With an informational text about the error occurred.
ACTION_BARCODE_SCANNER_RECONNECTING - This event is issued if the application is in automatic. It is triggered after each failed connection attempt.
ACTION_BARCODE_SCANNING_START - When the application has detected a capture from the connected scanner.
ACTION_BARCODE_SCANNING - When the received code has been processed and is ready to be notified. This event receives the following extras:
EXTRA_BARCODE - Which stores the code captured by the scanner inside.
EXTRA_BARCODE_FORMAT - Blue - Bars is able, at the moment, to identify the captured code in the following formats, EAN 8, EAN 13, UPCA, UPCE, CODE 39, CODE 93, CODE 128 and QR.
ACTION_BITMAP_BARCODE_CREATED - Blue - Bars generates in each capture an image of the captured barcode, taking into account the formats accepted by the application. This image will be received by the following extra;
EXTRA_BITMAP_BARCODE - The received image will be a BitMap Compressed in a character string in base 64. To retrieve it, it must be decompressed using, for example, the following function written in Java.
public Bitmap StringToBitMap(String encoded)
{
try {
byte [] myByte = Base64.decode( encoded, Base64.DEFAULT );
Bitmap bitmap = BitmapFactory.decodeByteArray(myByte , 0,
myByte.length);
return bitmap;
} catch(Exception e) {
e.getMessage();
return null;
}
}
ROAD SHEET
- Create a configuration screen for the application.
- Give the possibility to send the scanned codes to other devices such as computers (using a TCP connection), other smartphones (using Bluetooth) or to a server (using a simple client server model).
- Create lists of scanned barcodes, and send them all at once using the broadcast events and connections described in the previous point.