- hints = new Hashtable<DecodeHintType, Object>(3);
- Vector<BarcodeFormat> vector = new Vector<BarcodeFormat>();
- vector.addElement(BarcodeFormat.QR_CODE);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
- }
-
- private void captureAndDecode() {
- Date startDate = new Date();
- Bitmap bitmap = cameraManager.captureStill();
- // Let the CameraThread know it can resume previews while the decoding continues in parallel.
- Message restart = Message.obtain(cameraThreadHandler, R.id.decode_started);
- restart.sendToTarget();
-
- if (tracing) {
- Debug.startMethodTracing("/sdcard/ZXingDecodeThread" + methodTraceCount);
- methodTraceCount++;
- }
- boolean success;
- Result rawResult = null;
- try {
- MonochromeBitmapSource source = new RGBMonochromeBitmapSource(bitmap);
- rawResult = new MultiFormatReader().decode(source, hints);
- success = true;
- } catch (ReaderException e) {
- success = false;
- }
- if (tracing) {
- Debug.stopMethodTracing();
- }
- Date endDate = new Date();
-
- if (success) {
- Message message = Message.obtain(cameraThreadHandler, R.id.decode_succeeded, rawResult);
- message.arg1 = (int) (endDate.getTime() - startDate.getTime());
- message.sendToTarget();
- } else {
- Message message = Message.obtain(cameraThreadHandler, R.id.decode_failed);
- message.sendToTarget();
- }