I have heard that the easiest way to implement ZXing barcode scanner into your own app is with an intent. However, nobody has explained how to do this in Android Studio. There's explanations for how to do it in Eclipse and Maven, but not Android Studio. Do I need to download anything other than the ZXing barcode scanner app, to implement it via intent? I think intents just call another app, but I'm not completely sure. Do I need to download a dependency (such as an AAR, JAR, or JAVA file) to get the ZXing intent to be accessible to an app? Please let me know how to use INTENTS with ANDROID STUDIO, in such a manner as to make it possible for the app I'm writing to use ZXing as its barcode scanner.
Asked
Active
Viewed 2,038 times
0
-
Intents are specific to Android platform not an IDE. – Eugen Pechanec May 25 '16 at 08:27
2 Answers
1
You can use ZXing in you app via gradle dependency . Add the following dependencies to your gradle file
compile 'com.journeyapps:zxing-android-embedded:3.1.0@aar'
compile 'com.google.zxing:core:3.2.0'
Then on your activity's onCreate
method , add the following
IntentIntegrator scanIntegrator = new IntentIntegrator(MainActivity.this);
scanIntegrator.setPrompt("Scan a barcode");
scanIntegrator.setBeepEnabled(true);
scanIntegrator.setOrientationLocked(true);
scanIntegrator.setBarcodeImageEnabled(true);
scanIntegrator.initiateScan();
This will start a the scanner when you launch the Activity .
You can get the scan result , in onActivityResult
@Override
protected void onActivityResult(final int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
/*As an example in order to get the content of what is scanned you can do the following*/
String scanContent = scanningResult.getContents().toString();
}

Mithun Sarker Shuvro
- 3,902
- 6
- 32
- 64
-
Interesting. I know this is old, but I'm still wondering if adding dedpendencies can be done in a menu in the IDE rather than needing to edit text files? – Ben Hutchinson Jun 26 '23 at 01:29
0
You can Develop your own Bar-Code Scanner App: Try this references,
This is ZXing Jar Download Link: http://www.java2s.com/Code/Jar/z/Downloadzxingjar.htm
This is ZXing used to implement Barcode Scanner Reference Link: http://khurram2java.blogspot.in/

Sackurise
- 2,804
- 1
- 18
- 18