I\'m trying to add ZXing to my project (add a button which calls the scanner upon press). I found this: http://groups.google.com/group/android-developers/browse_thread/threa
I use Zxing in a tab (a Fragment) and use the support library (for Material Design components) so I had to call it like this:
IntentIntegrator integrator = new IntentIntegrator(getActivity()); integrator.forSupportFragment(this).initiateScan();
then in onActivityResult()
if (resultCode == Activity.RESULT_OK) {
if (requestCode == IntentIntegrator.REQUEST_CODE) {
String contents = data.getStringExtra("SCAN_RESULT");
String format = data.getStringExtra("SCAN_RESULT_FORMAT");
Log.i(TAG, "Barcode Result: " + contents);
etc...
}
}
and in my Manifest.xml
It all works very nicely now. I was not successful just using intents and startActivityForResult(). The scanner would start and fix on the QRcode but did not return.
In my build.grade, I have:
repositories { mavenCentral() maven { url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/" } }
compile 'com.google.zxing:core:3.2.1'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'