我不知道为什么但是当我在我的
Android应用程序中使用zxing来获取条形码时,格式返回为EAN_13但是我的if staement决定它不是,然后在我的Toast通知中显示EAN_13.关于它为什么破碎的任何线索?
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
if (resultCode == 0){
//If the user cancels the scan
Toast.makeText(getApplicationContext(),"You cancelled the scan", 3).show();
}
else{
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT").toString();
if (format == "EAN_13"){
//If the barcode scanned is of the correct type then pass the barcode into the search method to get the product details
Toast.makeText(getApplicationContext(),"You scanned " + contents, 3).show();
}
else{
//If the barcode is not of the correct type then display a notification
Toast.makeText(getApplicationContext(),contents+" "+format, 3).show();
}
}
}
}
本文探讨了在Android应用中使用zxing扫描条形码时遇到的问题,特别是当期望的EAN_13格式未被正确识别的情况。通过分析代码片段,本文提供了调试和解决此类问题的方法。
426

被折叠的 条评论
为什么被折叠?



