qr code generation function kotlin
//Usage
val bitmap = generateQRCode("Sample Text")
imageView.setImageBitmap(bitmap)
qr code generation function kotlin
//Usage
val bitmap = generateQRCode("Sample Text")
imageView.setImageBitmap(bitmap)
qr code generation function kotlin
//Code
private fun generateQRCode(text: String): Bitmap {
val width = 500
val height = 500
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val codeWriter = MultiFormatWriter()
try {
val bitMatrix = codeWriter.encode(text, BarcodeFormat.QR_CODE, width, height)
for (x in 0 until width) {
for (y in 0 until height) {
bitmap.setPixel(x, y, if (bitMatrix[x, y]) Color.BLACK else Color.WHITE)
}
}
} catch (e: WriterException) {
Log.d(TAG, "generateQRCode: ${e.message}")
}
return bitmap
}
qr code generation function kotlin
//Dependency
implementation 'com.google.zxing:core:3.4.0'
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us