Reputation: 105
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
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