我正在使用https://github.com/zxing集成条形码扫描仪。我想传递一些额外的数据 - uuid
以及条形码。
以下uuid1
和uuid2
都会产生null
。我错过了什么?
public void startScanner(String uuid){
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.PRODUCT_CODE_TYPES);
integrator.setPrompt("");
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
Intent intent = integrator.createScanIntent();
intent.putExtra("uuid", uuid);
startActivityForResult(intent, IntentIntegrator.REQUEST_CODE);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
String code = scanResult.getContents();
JSONObject json = new JSONObject();
try {
String uuid1 = intent.getStringExtra("uuid");
String uuid2 = intent.getExtras().getString("uuid");
json.put("uuid", uuid1);
json.put("barCode", code);
this.webViewManager.runScript("startScannerCallback", json);
} catch (JSONException e) {
e.printStackTrace();
}
}
}