Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – QR code with logo cannot be recognized by my app’s QR code scanner

Posted on November 11, 2022 By

Solution 1 :

I fixed it… The problem is in-app browsers cannot process websites that are built using Javascript.

This is what my code for launching the browser looks like before and after:

Before:

@Composable
fun LoadWebUrl(url: String) {
val context = LocalContext.current
AndroidView(factory = {
    WebView(context).apply {
        webViewClient = WebViewClient()
        loadUrl(url)
    }
})
}

After:

@Composable
fun LoadWebUrl(url: String) {
val context = LocalContext.current
IntentUtils.launchBrowser(context, url)
}

Problem :

I have created an app with QR code scanner, however I can’t scan a QR code with a logo using it, any solution for this?

This is the code of my QR code scanner app:

class QRCode (val onQrCodeScanned: (String) -> Unit) : ImageAnalysis.Analyzer {

@RequiresApi(Build.VERSION_CODES.M)
private val supportedImageFormats = listOf(
        ImageFormat.YUV_420_888 ,
        ImageFormat.YUV_422_888 ,
        ImageFormat.YUV_444_888)

@RequiresApi(Build.VERSION_CODES.M)
override fun analyze(image: ImageProxy) {
    if (image.format in supportedImageFormats) {
        val bytes = image.planes.first().buffer.toByteArray()

        val source = PlanarYUVLuminanceSource(
                bytes,
                image.width,
                image.height,
                0,
                0,
                image.width,
                image.height,
                false)
        val binaryBmp = BinaryBitmap(HybridBinarizer(source))
        try {
            val result = MultiFormatReader().apply {
                setHints(
                        mapOf(
                                DecodeHintType.POSSIBLE_FORMATS to arrayListOf(
                                        BarcodeFormat.QR_CODE
                                                                              )
                             )
                        )
            }.decode(binaryBmp)
            onQrCodeScanned(result.text)
        } catch (e: Exception) {
            e.printStackTrace()
        } finally {
            image.close()
        }
    }
}

private fun ByteBuffer.toByteArray(): ByteArray {
    rewind()
    return ByteArray(remaining()).also {
        get(it)
    }
}

}

It can scan other QR codes but not QR codes with logo.

This is my QR code:
enter image description here

Comments

Comment posted by Aj Catindig

@blackapps already added it.

Comment posted by Lalit Fauzdar

Although you’ve fixed your problem, but I had developed a highly advanced QR app once and I’d suggest you should switch to Google Mobile Vision from Zxing, Google’s one performs way better.

Comment posted by blackapps

????? What has launching a website to do with decoding a qr-code?

Comment posted by Aj Catindig

@blackapps the QR code contains a link to the URL of a web page that I have created using javascript. I think in-app browser of android apps doesn’t have a support for those kind of websites that’s why it’s not loading it.

READ  [FIXED] android - foreign key error expected error
Powered by Inline Related Posts

Android Tags:android, kotlin, qr-code

Post navigation

Previous Post: [FIXED] android – LottieAnimationView doesn’t show in my_layout.xml
Next Post: [FIXED] android – Firestore conditional array query

Related Posts

[FIXED] api – Minimum Android OS versions for WebP images support Android
[FIXED] java – MaterialAnimatedSwitch saving state Android
[FIXED] java – Flutter android App crashes when trying to debug after signing release Android
[FIXED] Android Studio – How to have a transparent status bar? Android
[FIXED] javascript – Using Linked Lists in Checkerbox selection List react-native Android
[FIXED] android – Why am I getting an .aab file instead of a .apk file? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme