Deprecation warning
Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.
We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.
You'll find the updated documentation at: Data Capture SDK Documentation for Android
Motivation
When a barcode is scanned, then the phone will be vibrating/beeping, and the recognized code might be visually highlighted depending on the GUI style used. However, you might want to apply your own logic (i.e. validate that the code is in your database) before accepting a code.
Code Rejection
In order to be able to accept only a subset of the codes, it is necessary to enable code rejection.
Once this is done, you can use rejectCode(Barcode) method to reject individual codes. Here you can find an example where we iterate through all the recognized codes and possibly reject a few of them after calling shouldRejectCode()
which is the method containing the app logic used to decide whether to reject the code or not.
Please note that rejectCode()
must be called from the session queue.