This is the library modified from the original ZXing Project. The code is not modified in any way but is just compiled into a library so that the end user doesn't have to download the scanner app separately.

Adding the library

Add this line (if not already present there) in the project's build.gradle file

repositories {

Add this statement in the dependencies block of app's build.gradle file

compile 'com.tarun0.zxing-standalone:zxing-standalone:1.0.0'


Send an intent when you need to scan, like on clicking on a button

Intent intent = new Intent(getApplicationContext(),CaptureActivity.class);
            intent.putExtra("SAVE_HISTORY", false);
            startActivityForResult(intent, 0);

Handle the result from the intent by overriding onActivityResult

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                String contents = data.getStringExtra("SCAN_RESULT");
                Log.d(TAG, "contents: " + contents);
            } else if (resultCode == RESULT_CANCELED) {
                Log.d(TAG, "RESULT_CANCELED");