是否有可能在我自己的Activity(我的xml文件)中恢复创建QR码ZXing的结果?
答案 0 :(得分:0)
不确定这是否是您要求的,但您可以使用ZXING从您的某项活动中扫描条形码:
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
}
catch (ActivityNotFoundException e) {
}
使用条形码执行某些操作包括:
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");
Toast.makeText(this, contents, Toast.LENGTH_SHORT).show();
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
您需要在设备上安装ZXING barcode app。