android中条形码扫描器集成的问题

时间:2011-06-28 11:45:59

标签: android barcode-scanner

我想通过链接zxing here

在android中执行条形码扫描程序

但问题是,它显示了摄像头视图,但它无法扫描条形码图像。我不明白是什么问题?请指导我。

是否有其他程序而非上述链接?

1 个答案:

答案 0 :(得分:2)

我第一次使用ZXing时遇到了同样的问题。

开始ZXing活动时,您需要确保要求正确的条形码格式。

致电时(根据例子)

intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

我猜你真的想用

intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

确保根据Intents.java文件包含正确的条形码格式:

/**
 * By default, sending Scan.ACTION will decode all barcodes that we understand. However it
 * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
 * one of the values below.
 *
 * Setting this is effectively shorthand for setting explicit formats with {@link #FORMATS}.
 * It is overridden by that setting.
 */
public static final String MODE = "SCAN_MODE";

/**
 * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
 * prices, reviews, etc. for products.
 */
public static final String PRODUCT_MODE = "PRODUCT_MODE";

/**
 * Decode only 1D barcodes.
 */
public static final String ONE_D_MODE = "ONE_D_MODE";

/**
 * Decode only QR codes.
 */
public static final String QR_CODE_MODE = "QR_CODE_MODE";

/**
 * Decode only Data Matrix codes.
 */
public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";

/**
 * Comma-separated list of formats to scan for. The values must match the names of
 * {@link com.google.zxing.BarcodeFormat}s, e.g. {@link com.google.zxing.BarcodeFormat#EAN_13}.
 * Example: "EAN_13,EAN_8,QR_CODE"
 *
 * This overrides {@link #MODE}.
 */