I use com.google.android.gms.vision.barcode.BarcodeDetector
in order to read QR codes. The problem is these codes carry raw binary data; no phone numbers, no URLs, no geopoints... I cannot change these QR codes, because they are generated in a different application.
When I scan these QR codes using Android Barcode API, the resulting Barcode
object doesn't allow me to access the raw data, although it must know it!
All I get is "Unknown encoding"
message both in rawValue
and displayValue
properties.
Having a byte[]
property instead of two String
properties would make more sense, since QR codes can carry general data.
I don't see the point of hiding raw data byte array from developers. Could I somehow extend the BarcodeDetector
class or the Barcode
class to get what I need?
Edit:
This is an absolutely valid QR code, which cannot be read by Vision API, although it carries 1024 bytes of data:
QR Codes - raw binary data is related, but it doesn't solve my problem.
Are QR Code patterns the same for identical data? Even if two QR Codes store identical data, the pattern might or might not be different depending on the QR Code generator used. The primary reason for the change is due to the internal expression of the QR Code (numeric code, alphanumeric code, and so on).
On your compatible Android phone or tablet, open the built-in camera app. Point the camera at the QR code. Tap the banner that appears on your Android phone or tablet. Follow the instructions on the screen to finish signing in.
QR Code readingSimply select an area with a QR Code and the program will automatically scan it. You can scan QR codes from websites, documents, movie files – you name it. You can also select an image file that contains a QR Code and the program will locate it automatically and decode it.
I think you need to write some of the implementation yourself. As I can clearly see in the API that the rawData is held by String which simply does not ensure the integrity of your binary data type.
I will write my own BarcodeDetector with my own BarCode object with byte[] as data type for rawData coming from QR-Code and override detect() method to assign the rawData to my BarCode implementation. As your case is very specific to the requirement you should not hesitate to write your own implementation. May be share it on github for others too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With