21

I want to create an application for Android that will be able to scan barcodes, get the information contained within the barcode and then be able to use that information in some way.

I have no idea how to create a barcode scanner so I went Googling and it seems Zxing is the most commonly used way to implement a barcode scanner in an app.

Some Links:


http://code.google.com/p/zxing/

http://awalkingcity.com/blog/2008/08/25/qr-codes-made-easy-in-android/

Using ZXing to create an android barcode scanning app


However the samples I found on zxing involved having to prompt the user to go to the market and install the zxing barcode scanner so that my app can then call the barcode scanner when its needed and the barcode scanner will then return the info to my app.

While this would be a good starting point for me I was wondering is there any other options that would allow me to have a barcode scanner embedded in my own application without having to prompt the user to download a secondary application?

4

7 Answers 7

21

Developer here. I think you're going to want to just integrate via Intent in the end. You get the improvements, bug fixes, and platform-specific workarounds for free. It's much less code too. But I understand you're asking for an alternative.

You probably want to strip down Barcode Scanner (whose source is in android/ in the project) and strip out everything you don't need. That means leave only about the com.google.zxing.client.android and com.google.zxing.client.android.camera packages. The core decoding is in DecodeThread, but the other code in these packages implements the little callback dance that does the continuous scanning and gets the usual scanning UI.

If you embed the code you need to follow the terms of the Apache License.

3
  • @james-baca your edit to my answer was basically vandalism and has been rolled back. Write your own answer advertising your service.
    – Sean Owen
    Aug 22, 2015 at 19:07
  • er, and by that I meant the Google Play Service, which is a great thing. Point was about overwriting someone else's answer in an edit.
    – Sean Owen
    Aug 22, 2015 at 19:27
  • I made code for barcode generate and scan barcode. You can follow this to get the Step By Step Code. stackoverflow.com/a/58742737/11613683 Nov 7, 2019 at 9:29
7

Download and extend the Zxing "Barcode Scanner" app by adding your own code. It's under an Apache 2.0 License.

2
  • So essentially take the Zxing source code and rewrite it to do what I want? Apr 9, 2010 at 13:55
  • That would be my recommendation. You could probably just include the existing source, invoke it, and capture the returned barcode pretty easily. I'd guess you wouldn't have to change very much of the code at all.
    – Chris K
    Apr 9, 2010 at 17:18
7

The Google Mobile Vision is deprecated and replaced with ML Kit. https://developers.google.com/ml-kit/vision/barcode-scanning It provides sdks on both android and iOS and is getting actively improved with the latest google technology. For android, it provides sdks that can bundle the model and also provides SDK that can fetch model from Google play service automatically if you want to save your app's size.

4

Check out the new Google Play Services 7.8 API that includes Barcode tracking: https://developers.google.com/vision/barcodes-overview

1
2

I'd suggest you use Zxing through intents and redirect to Android Market page ("market://details?id=com.google.zxing.client.android") if it's not there (catching ActivityNotFoundException). Intents are great for inter-app communications like this.

1
  • 4
    Yes I'm aware I can do that, but what I want is alternatives to having to ask a user to install a seperate app just for the scanning Apr 9, 2010 at 14:19
1

I recommend to use google barcode scan. It is pretty responsive. It is called Google Mobile Vision.

The Barcode Scanner API detects barcodes in real time in any orientation. You can also detect and parse several barcodes in different formats at the same time.

https://developers.google.com/vision/

https://codelabs.developers.google.com/codelabs/bar-codes/#0

1
  • The Google Mobile Vision is deprecated and replaced with ML Kit. developers.google.com/ml-kit/vision/barcode-scanning It provides sdks on both android and iOS and is getting actively improved with the latest google technology. For android, it provides sdks that can bundle the model and also provides SDK that can fetch model from Google play service automatically if you want to save your app's size. Mar 2, 2021 at 21:45
0

I have it working with this:

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'

I recommend using the IntentIntegrator

IntentIntegrator integrator = new IntentIntegrator(getActivity()); 
integrator.forSupportFragment(this).initiateScan();

The requestCode comes back with

IntentIntegrator.REQUEST_CODE

No need to install a separate scanner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.