此代码扫描单个记录返回到我的应用程序。 如何扫描多条记录而不返回。
Intent intentScan = new Intent(“com.google.zxing.client.android.SCAN”); intentScan.addCategory(Intent.CATEGORY_DEFAULT);
String targetAppPackage = findTargetAppPackage(intentScan);
if (targetAppPackage == null) {
return showDownloadDialog();
}
intentScan.setPackage(targetAppPackage);
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
attachMoreExtras(intentScan);
startActivityForResult(intentScan, 0);
答案 0 :(得分:2)
像这样更新你的onActivityResult方法
//method for getting qr code from qr code after scan
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
Toast.makeText(this, contents , Toast.LENGTH_SHORT).show();
//start activity for scanning qr code
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
Log.d("the result is","not ok");
}
}