I implemented the scandit library in my google glass project, but if I'm scanning EAN-13 barcodes the last digit is always wrong. For example: I'm scanning a code with the value 2220141633626 and the result is 2220141633624.
This is my code in Activity 1:
public void didScanBarcode(String content, String format) {
// send the result to another activity.
Intent resultIntent = new Intent(this, TestingActivity.class);
resultIntent.putExtra("scanContent", content);
Log.v("scanbarcode", content);
startActivity(resultIntent);
}
This is my code in Activity 2:
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.testing);
Intent resultIntent = getIntent();
String scanContent = resultIntent.getExtras().getString("scanContent");
serialNumber = Long.parseLong(scanContent);
Log.e("string ", "" + scanContent);
Log.e("long ", "" + serialNumber);
}
The content is already wrong in the didScanBarcode method of my first activity.
2220141633626
is not a valid EAN-13 code, while2220141633624
is.The first 12 numbers are the actual number, while the 13th is the 'check digit'. The check digit of
222014163362
is4
.See for example http://www.morovia.com/education/utility/upc-ean.asp, enter
222014163362
in the ean-13 field and press 'calculate'