我正在使用 ZXing Library 作为我的 Android 项目的库。但是,每当扫描条码时,ZXing Capture 活动都不会向我的活动提供结果,它只是站在那里,就好像代码已通过应用程序正常扫描一样。
我目前的代码是:
discount.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(DiscountActivity.this, CaptureActivity.class);
intent.setAction("com.google.xzing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.discount_dialog);
dialog.show();
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}