-1
在扫描条形码后,我很难让zxing做任何事情。我打电话使用斑马线:不知道我在用IntentIntegrator做什么
IntentIntegrator.initiateScan(MainActivity.this);
而且我onActivityResult看起来像这样
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");
if (format == "PRODUCT_CODE"){
//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(),"You didn't scan a product code", 3).show();
}
} else if (resultCode == RESULT_CANCELED) {
//If the scan is cancelled then display a notification
Toast.makeText(getApplicationContext(),"You cancelled the input", 3).show();
}
}
}
但每当我退出斑马线没有任何显示。我尝试使用in the zxing wiki 示例,但每当我尝试用MainActivity或MainActivity替换yourActivity时,我收到错误(我得到的消息告诉MainActivity无法解析为字符串,而MainActivity.this构造函数IntentIntegrator(MainActivity)未定义)。
基本上我不知道我在做什么,为什么它不工作。任何帮助将不胜感激。