If you want to use ZXing for barcode reading, but do not want your customer to install a third party app. Or if you just can’t because the Android device you are using cannot connect to the Play store (as is the case with many wearables), there is an extremely easy way to use the ZXing scanner in your app, using Android Studio. No need to download anything, install libraries, compile entire code trees:

To embed the library, add these two lines to your app.gradle:

dependencies {
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'com.google.zxing:core:3.2.1'

Then, to initiate a scan, call this in your Activity:

new IntentIntegrator(this).initiateScan();

Finally, you use this code to receive the result:

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == 0) {
      if (resultCode == RESULT_OK) {
         String contents = intent.getStringExtra("SCAN_RESULT");
         String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
         // Handle successful scan
      } else if (resultCode == RESULT_CANCELED) {
         // Handle cancel


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.