I am using zxing to implement a barcode scanner in my application . The issue is the scan result is always detecting UPC-E as the scan format and returning a wrong result. Any way to solve this ?
I am initiating the scan with the following code :
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
startActivityForResult(intent, 0);
and the OnActivity block is as follows :
@Override
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");
Log.d("SEARCH_EAN", "OK, EAN: " + contents + ", FORMAT: " + format);//this is the result
} else
if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
Barcode scanner has been installed using Barcode-4.7.3.apk Any leads will be appreciated.
You have a number of things wrong with your example. First, you are adding core library code that you don't need, since you are integrating by Intent
.
Second, for some reason you are invoking the scan twice. The second set of code does nothing. The camera param code also does nothing.
Third I think you're using a different project, not zxing
for integration, since there is no setDesiredBarcodeFormats
method in the project. Unless I'm forgetting this was in an old version or something.
Finally, you are scanning for all ONE_D_CODE_TYPES
instead of the format you want.