I am working on developing an inventory tracking application for android uing zxing barcode scanner integration. The problem I am currently having is providing the product information that zxing is able to display after a scan by querying google products. At least thats how I think that zxing gets the information. Any ideas on how I can implement this. I am able to scan the barcode and get the upc # but how can I then have it return product information from a query to a upc database or google product search?
Any help, insight, ideas would be greatly appreciated. Thanks.
Both parts of code below are part of AddItem.java that extends Activity and implements OnClickListener:
- Code: Select all
public void onClick(View v) {
switch (v.getId()) {
case R.id.scanButton:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, REQUEST_BARCODE);
break;
case R.id.addButton:
String barcode = mBarcodeEdit.getText().toString();
String format = mFormatEdit.getText().toString();
String title = mTitleEdit.getText().toString();
String price = mPriceEdit.getText().toString();
String errors = validateFields(barcode, format, title, price);
if (errors.length() > 0) {
showInfoDialog(this, "Please fix errors", errors);
} else {
mItemData.barcode = barcode;
mItemData.format = format;
mItemData.title = title;
mItemData.price = new BigDecimal(price);
mItemDb.insert(mItemData);
showInfoDialog(this, "Success", "I saved successfully");
resetForm();
}
break;
}
}
- Code: Select all
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == REQUEST_BARCODE) {
if (resultCode == RESULT_OK) {
String barcode = intent.getStringExtra("SCAN_RESULT");
mBarcodeEdit.setText(barcode);
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
mFormatEdit.setText(format);
}
else if (resultCode == RESULT_CANCELED) {
finish();
}
}
}


