How to use IntentIntegrator to get a proper IntentResult? [question]
See original GitHub issueI 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:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 varnamedata
! And as there is an Activity’s propertyintent
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 !
Yes. It’s not published anymore but this was the last version: https://github.com/zxing/zxing/blob/zxing-3.3.0/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java