我不知道为什么但是当我在我的
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();
}
}
}
}