ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Bar Code functions
  • Use conditions
  • Error handling
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Decodes the information stored in a bar code by using the device camera (Android, iPhone, iPad).
Tip: Use the Camera control whenever possible:
Example
// Decode a QR Code
bc is BarCode
bc = BCCapture()
IF ErrorOccurred = False _AND_ bc.TypeContent = bcTypeEmail THEN
    Info("Email address: " + bc.RoughValue)
END
Syntax
<Result> = BCCapture([<Bar code type> [, <Enable flash>]])
<Result>: BarCode variable
BarCode variable initialized with the information read in the bar code.
iPhone/iPadIOS WidgetMac Catalyst 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:
BC_AZTECAztec bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE128Code128 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE39Code39 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE93Code93 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_DATAMATRIXDATAMATRIX bar code.
iPhone/iPadIOS WidgetMac Catalyst Not available.
BC_EAN128EAN128 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_EAN13EAN13 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_EAN8EAN8 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_INTER2OF5Interleaved 2 of 5 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_PDF417PDF417 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_QRCODEQR Code bar code.
BC_UPCAUPC-A bar code.
iPhone/iPadIOS WidgetMac Catalyst Not available.
BC_UPCEUPC-E bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_ALLAll the types of bar codes supported by this function can be decoded.

If this parameter is not specified, all types of codes supported by this function can be decoded.
iPhone/iPadIOS WidgetMac Catalyst Starting with IOS 7, the following bar codes can be decoded: QR Code, UPCE, Code39, Code39Mod43, EAN13, EAN8, Code93, Code128, PDF417 and Aztec.
<Enable flash>: Optional boolean
iPhone/iPadIOS WidgetMac Catalyst Flash management mode:
  • True to enable the flash,
  • False (default) to disable the flash.
Remarks

Use conditions

AndroidAndroid Widget 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.
iPhone/iPadIOS WidgetMac Catalyst For iPhone/iPad applications:
  • BCCapture opens a new window that displays the camera preview stream. Then, you just need to center the bar code to decode in the relevant area.
  • The window used to take photos is included in the WINDEV Mobile application. No additional library is required.
  • Version earlier than iOS 7: Only QR Codes can be decoded. If another type of bar code is scanned, it will no be decoded. The "Cancel" button in the decoding window closes the window. In this case, the BarCode variable is not initialized.

Error handling

To determine whether the bar code failed to be read, use the ErrorOccurred variable.
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.
  • iPhone/iPadIOS WidgetMac Catalyst if the "Cancel" button was used. In this case, the TypeBarCode property of the BarCode variable will be different from BC_QRCODE.
Android If the barcode is decoded but its type is not recognized, the TypeBarCode property of the BarCode variable will correspond to the BC_UNKNOWN constant.
AndroidAndroid Widget

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.
Tips:
  • 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.
Business / UI classification: Neutral code
Component: wd290android.aar
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 06/23/2023

Send a report | Local help