- Use conditions
- Error handling
- Application in the background: Specific case from Android 10
In french: CBCapture
Decodes the information stored in a bar code by using the device camera (Android, iPhone, iPad).
Tip: Use the Camera control whenever possible:
// Decode a QR Code
bc is BarCode
bc = BCCapture()
IF ErrorOccurred = False _AND_ bc.TypeContent = bcTypeEmail THEN
Info("Email address: " + bc.RoughValue)
<Result> = BCCapture([<Bar code type> [, <Enable flash>]])
<Result>: BarCode variable
BarCode variable initialized with the information read in the bar code.
Remark: The TypeBarCode
property of the BarCode
variable is not updated: it always corresponds to "QRCode".
<Bar code type>: Optional Integer constant
Type of bar code that can be decoded:
If this parameter is not specified, all types of codes supported by this function can be decoded.
<Enable flash>: Optional boolean
In an Android application:
- BCCapture opens a new window that displays the camera preview stream. Then, you must:
- center the bar code to decode in the relevant area.
- tap to read the bar code.
- The Zxing library is used to decode bar codes (http://code.google.com/p/zxing). If this library is not on the device, it will be automatically available for download.
Caution: This library requires the landscape mode of the device.
To determine whether the bar code failed to be read, use the ErrorOccurred
The function will fail in the following cases:
- if it is used in the simulator,
- if it is used in the emulator,
- if it is used in a device not equipped with a camera.
- if the "Cancel" button was used. In this case, the TypeBarCode property of the BarCode variable will be different from BC_QRCODE.
If the barcode is decoded but its type is not recognized, the TypeBarCode
property of the BarCode
variable will correspond to the BC_UNKNOWN
Application in the background: Specific case from Android 10
From Android 10, it is no longer possible to open a window when the application is in the background.
BCCapture can open a window. If this function is used while the application is in the background, a fatal error will occur.
- It is possible to determine if the application is in the background using InBackgroundMode.
- If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Cross-platform examples (WINDEV Mobile): WM Stocks
[ + ]
This application is used to perform stocktaking and to save the results in a database.
The example is used to create entries/exits in the stock, by directly scanning the bar code of products.
It is optimized to be run on tablets.
Android (WINDEV Mobile): Android Inventory
[ + ]
This application is used to perform inventories and to save the results in a database.
Business / UI classification: Neutral code