Haritha Reddy
Haritha Reddy

Reputation: 105

Want to integrate zxing library in to my application

I integrated zxing libary using this tutorial http://www.androidaz.com/development/zxing-qr-reader-direct-integration, but i can not able to read QR Code continuously it is in progress of reading .

Upvotes: 0

Views: 80

Answers (2)

Frank Fung
Frank Fung

Reputation: 165

For me, I will use original Intent method for your case. There should have an android version for the zxing library for the barcode scanning. Unlike the page you have mentioned, you will have to include the below in your androidManifest.xml inside application tag:

<activity
        android:name="com.google.zxing.client.android.CaptureActivity"
        android:clearTaskOnLaunch="true"
        android:screenOrientation="sensorLandscape"
        android:stateNotNeeded="true"
        android:theme="@style/CaptureTheme"
        android:windowSoftInputMode="stateAlwaysHidden" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.google.zxing.client.android.SCAN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

In your Activity Class, you should call the barcode scanner by using intent as follow:

private final int QR_CODE = 0;
try {
        Intent intent = new Intent(
                "com.google.zxing.client.android.SCAN");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
        intent.putExtra("SCAN_MODE", "SCAN_MODE");
        startActivityForResult(intent, QR_CODE);
} catch (Exception e) {
            //Handle the case when barcode scanner is absence.
}

and handle the result from the barcode scanner using:

@Override
protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    if (requestCode == QR_CODE) {
        if (resultCode == RESULT_OK) {
            String code = intent.getStringExtra("SCAN_RESULT");
//you should handle recall of the barcode scanner using intent here
        }else if (resultCode == RESULT_CANCELED) {{
            //user cancelled barcode scanning process.
        }
    }
}

Hope that the above code could provide some idea for your case.

Upvotes: 1

dvs
dvs

Reputation: 644

I recently completed working on QR Code scanner. you should use this library. How to use it is explained properly and it works great. It also scans continuously, so it will solve that problem of yours as well.

Let me know if you need any other help.

Upvotes: 1

Related Questions