Search code examples
androidzbar

Android ZBar QR Code Scanner - How to read every QR Code


I currently implemented ZBar QR Code Scanner Library into my own app. But, so far, I am just able to read a QR Code that leads to a website. What should I do if I want to scan a QR Code that leads you to dial a phone number or text messages? How do I make my app read any QR Code?


Solution

  • The content of the QR code should be irrelevant -- it's just text. It might happen to contain a URL, but that doesn't change the format of the QR code.

    int result = imageScanner.scanImage(image);
    
    // Nonzero means a result was found
    if (result != 0) {
    
        // Typical only one symbol unless multiple codes were found
        // in the scanned image
        for (Symbol symbol : imageScanner.getResults()) {
    
            // .getData() gives the string content of the QR code
            String qrCodeContent = symbol.getData();
        }
    }