plexus
plexus

Reputation: 111

How to generate QR code that stores multiple values

I wanted to generate a QR code that contains JSON data, I found this as an example. This question suggested to use Gson but my project uses Odoo mobile framework and it has an existing Gson in the directory and tried to implement it but it would cause an error. Is there another way to store multiple values in QR code?

Upvotes: 0

Views: 582

Answers (1)

Husnain Rafique
Husnain Rafique

Reputation: 1

private fun generateQRCode(name: String, phone: String, email: 
String){
    val concatenatedValues = "$name\n$phone\n$email"
    val barcodeEncoder = BarcodeEncoder()
    val hints = mapOf(Pair(EncodeHintType.MARGIN, 0))
    val barCodeImage = 
barcodeEncoder.encodeBitmap(concatenatedValues,BarcodeFormat.QR_CODE, 400, 
400,hints)
binding.imgBarCode.setImageBitmap(barCodeImage)
}


private fun setUpQrCode(){
    val name = "Name = Husnain Ali Rafique"
    val phone = "Phone = 00000000000"
    val email = "Email = [email protected]"
    generateQRCode(name,phone,email)
}

this way by concatinating one can achieve this

Upvotes: 0

Related Questions