question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use IntentIntegrator to get a proper IntentResult? [question]

See original GitHub issue

I have loaded application from https://f-droid.org/en/packages/com.google.zxing.client.android/ and now is trying to write an app to use “Barcode Scanner”. I added code to Main Activity:

private fun doScan() {
    integrator = IntentIntegrator(this)
    dialog = integrator?.initiateScan()
}

Also I added onActivityResult:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    val scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent)
    if (scanResult != null) {
        AlertDialog.Builder(this).setMessage("Result: [$scanResult]").show()
    }
}

But all fields in scanResult contain “zeros”. What I did wrong? Or something is wrong with the build on f-droid?

Format: null
Contents: null
Raw bytes: (0 bytes)
Orientation: null
EC level: null

p.s. I also tried to build the app from a source code to discover the problem by myself but failed (#1257).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
c0dd3vi11commented, Feb 1, 2020

I found the a bug! >_<

I copied the code from https://zxing.github.io/zxing/apidocs/com/google/zxing/integration/android/IntentIntegrator.html, but there was an example written in Java. After I made a copy in Kotlin Android Studio’s snippet for onActivityResult I didn’t notice that instead of intent they use varname data! And as there is an Activity’s property intent I missed the mistake. You can see my mistake in the first message in the second code example.

So! Now everything work like a charm! ^_^ Than you for giving me advices, @srowen !

1reaction
srowencommented, Jan 31, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extracting results from Android ZXing IntentIntegrator
I have successfully extracted it. The scanned results is inside the string 'contents'. Lets say you scanned a code with name and id....
Read more >
IntentIntegrator (ZXing 3.3.2 API)
There are a few steps to using this integration. First, your Activity must implement the method Activity.onActivityResult(int, int, Intent) and include a line ......
Read more >
How to create your own QR Code and Barcode scanner ...
The testing of the App has been done using a real phone as camera features ... Intent data) { IntentResult intentResult = IntentIntegrator....
Read more >
QR code
You can use XYing website to create QR code ... IntentIntegrator.java and IntentResult.java ... If not, then it asks the user to get...
Read more >
Android QR Code Scanner – Quick Guide - Ronny Yabar
One problem, is that probably the user doesn't have the Barcode scanner app ... Now, we are going to use the IntentResult class,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found