com.google.zxing.Result#getText ( )源码实例Demo

下面列出了com.google.zxing.Result#getText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: vmqApk   文件: CaptureActivity.java
/**
     * Handler scan result
     *
     * @param result
     * @param barcode
     */
    public void handleDecode(Result result, Bitmap barcode) {
        inactivityTimer.onActivity();
        playBeepSoundAndVibrate();
        String resultString = result.getText();
        //FIXME
        if (TextUtils.isEmpty(resultString)) {
            Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
        } else {
            Intent resultIntent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString(Constant.INTENT_EXTRA_KEY_QR_SCAN, resultString);
            System.out.println("sssssssssssssssss scan 0 = " + resultString);
            // 不能使用Intent传递大于40kb的bitmap,可以使用一个单例对象存储这个bitmap
//            bundle.putParcelable("bitmap", barcode);
//            Logger.d("saomiao",resultString);
            resultIntent.putExtras(bundle);
            this.setResult(RESULT_OK, resultIntent);
        }
        CaptureActivity.this.finish();
    }
 
源代码2 项目: Elephant   文件: LoginActivity.java
@Override
public void handleResult(Result result) {
    String mUserName = "";
    String mLoginToken = "";
    String s = result.getText();
    if (!TextUtils.isEmpty(s) && s.contains(",")) {
        String[] data = s.split(",", 2);
        if (data.length == 2) {
            mUserName = data[0];
            mLoginToken = data[1];
        }
    }

    JLog.d("Login info: ", "UserName === " + mUserName + " LoginToken ======= "+ mLoginToken);

    mPresenter.login(this, mUserName, mLoginToken);
}
 
源代码3 项目: frpMgr   文件: ZxingUtils.java
/**
 * 二维码解码
 * 
 * @param imgPath
 * @return String
 */
public static String decode2(String imgPath) {
	BufferedImage image = null;
	Result result = null;
	try {
		image = ImageIO.read(new File(imgPath));
		if (image == null) {
			System.out.println("the decode image may be not exit.");
		}
		LuminanceSource source = new BufferedImageLuminanceSource(image);
		BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
		Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
		hints.put(DecodeHintType.CHARACTER_SET, "GBK");
		result = new MultiFormatReader().decode(bitmap, hints);
		return result.getText();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码4 项目: MiBandDecompiled   文件: URIResultParser.java
public URIParsedResult parse(Result result)
{
    String s = result.getText();
    if (s.startsWith("URL:"))
    {
        s = s.substring(4);
    }
    String s1 = s.trim();
    if (a(s1))
    {
        return new URIParsedResult(s1, null);
    } else
    {
        return null;
    }
}
 
源代码5 项目: DoraemonKit   文件: CaptureActivity.java
/**
 * Handler scan result
 *
 * @param result
 * @param barcode
 */
public void handleDecode(Result result, Bitmap barcode) {
    inactivityTimer.onActivity();
    playBeepSoundAndVibrate();
    String resultString = result.getText();
    if (TextUtils.isEmpty(resultString)) {
        Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
    } else {
        Intent resultIntent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putString(INTENT_EXTRA_KEY_QR_SCAN, resultString);
        resultIntent.putExtras(bundle);
        this.setResult(RESULT_OK, resultIntent);
    }
    CaptureActivity.this.finish();
}
 
源代码6 项目: QrCodeDemo4   文件: CaptureActivity.java
/**
     * Handler scan result
     *
     * @param result
     * @param barcode
     */
    public void handleDecode(Result result, Bitmap barcode) {
        inactivityTimer.onActivity();
        playBeepSoundAndVibrate();
        String resultString = result.getText();
        //FIXME
        if (TextUtils.isEmpty(resultString)) {
            Toast.makeText(CaptureActivity.this, "Scan failed!", Toast.LENGTH_SHORT).show();
        } else {
            Intent resultIntent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString(Constant.INTENT_EXTRA_KEY_QR_SCAN, resultString);
            System.out.println("sssssssssssssssss scan 0 = " + resultString);
            // 不能使用Intent传递大于40kb的bitmap,可以使用一个单例对象存储这个bitmap
//            bundle.putParcelable("bitmap", barcode);
//            Logger.d("saomiao",resultString);
            resultIntent.putExtras(bundle);
            this.setResult(RESULT_OK, resultIntent);
        }
        CaptureActivity.this.finish();
    }
 
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
  ResultPoint[] oldResultPoints = result.getResultPoints();
  if (oldResultPoints == null) {
    return result;
  }
  ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
  for (int i = 0; i < oldResultPoints.length; i++) {
    ResultPoint oldPoint = oldResultPoints[i];
    if (oldPoint != null) {
      newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
    }
  }
  Result newResult = new Result(result.getText(),
                                result.getRawBytes(),
                                result.getNumBits(),
                                newResultPoints,
                                result.getBarcodeFormat(),
                                result.getTimestamp());
  newResult.putAllMetadata(result.getResultMetadata());
  return newResult;
}
 
源代码8 项目: SimplifyReader   文件: DecodeUtils.java
public String decodeWithZxing(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(changeZXingDecodeDataMode());

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);

    Result rawResult = null;
    RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);

    if (source != null) {
        BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
        try {
            rawResult = multiFormatReader.decodeWithState(binaryBitmap);
        } catch (ReaderException re) {
            // continue
        } finally {
            multiFormatReader.reset();
        }
    }

    return rawResult != null ? rawResult.getText() : null;
}
 
源代码9 项目: o2oa   文件: CaptureActivity.java
/**
 * Handler scan result
 *
 * @param result
 * @param barcode 获取结果
 */
public void handleDecode(Result result, Bitmap barcode) {
    inactivityTimer.onActivity();
    playBeepSoundAndVibrate();
    String resultString = result.getText();
    // FIXME
    if (resultString.equals("")) {
        Toast.makeText(CaptureActivity.this, "没有扫描到任何东西!", Toast.LENGTH_SHORT)
                .show();
    } else {
        if (backResult) {
            Intent resultIntent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString(SCAN_RESULT_KEY, resultString);
            resultIntent.putExtras(bundle);
            this.setResult(RESULT_OK, resultIntent);
        } else {
            sendResultToWebLogin(resultString);
        }

    }
    CaptureActivity.this.finish();
}
 
源代码10 项目: ZXing-Orient   文件: ResultParser.java
protected static String getMassagedText(Result result) {
  String text = result.getText();
  if (text.startsWith(BYTE_ORDER_MARK)) {
    text = text.substring(1);
  }
  return text;
}
 
源代码11 项目: barcodescanner-lib-aar   文件: ResultParser.java
public static ParsedResult parseResult(Result theResult) {
  for (ResultParser parser : PARSERS) {
    ParsedResult result = parser.parse(theResult);
    if (result != null) {
      return result;
    }
  }
  return new TextParsedResult(theResult.getText(), null);
}
 
源代码12 项目: ZXing-Orient   文件: UPCAReader.java
private static Result maybeReturnResult(Result result) throws FormatException {
  String text = result.getText();
  if (text.charAt(0) == '0') {
    return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
  } else {
    throw FormatException.getFormatInstance();
  }
}
 
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
  ResultPoint[] oldResultPoints = result.getResultPoints();
  if (oldResultPoints == null) {
    return result;
  }
  ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
  for (int i = 0; i < oldResultPoints.length; i++) {
    ResultPoint oldPoint = oldResultPoints[i];
    newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
  }
  Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints, result.getBarcodeFormat());
  newResult.putAllMetadata(result.getResultMetadata());
  return newResult;
}
 
protected static String getMassagedText(Result result) {
  String text = result.getText();
  if (text.startsWith(BYTE_ORDER_MARK)) {
    text = text.substring(1);
  }
  return text;
}
 
源代码15 项目: BarcodeEye   文件: HistoryItemAdapter.java
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
  View layout;
  if (view instanceof LinearLayout) {
    layout = view;
  } else {
    LayoutInflater factory = LayoutInflater.from(activity);
    layout = factory.inflate(R.layout.history_list_item, viewGroup, false);
  }

  HistoryItem item = getItem(position);
  Result result = item.getResult();

  CharSequence title;
  CharSequence detail;
  if (result != null) {
    title = result.getText();
    detail = item.getDisplayAndDetails();      
  } else {
    Resources resources = getContext().getResources();
    title = resources.getString(R.string.history_empty);
    detail = resources.getString(R.string.history_empty_detail);
  }

  ((TextView) layout.findViewById(R.id.history_title)).setText(title);    
  ((TextView) layout.findViewById(R.id.history_detail)).setText(detail);

  return layout;
}
 
源代码16 项目: weex   文件: BookmarkDoCoMoResultParser.java
@Override
public URIParsedResult parse(Result result) {
  String rawText = result.getText();
  if (!rawText.startsWith("MEBKM:")) {
    return null;
  }
  String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true);
  String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true);
  if (rawUri == null) {
    return null;
  }
  String uri = rawUri[0];
  return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null;
}
 
源代码17 项目: jeewx-api   文件: QRCode.java
/**
 * 解析QRCode二维码
 */
@SuppressWarnings("unchecked")
public static void decode(File file) {
	try {
		BufferedImage image;
		try {
			image = ImageIO.read(file);
			if (image == null) {
				System.out.println("Could not decode image");
			}
			LuminanceSource source = new BufferedImageLuminanceSource(image);
			BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
			Result result;
			@SuppressWarnings("rawtypes")
			Hashtable hints = new Hashtable();
			//解码设置编码方式为:utf-8
			hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
			result = new MultiFormatReader().decode(bitmap, hints);
			String resultStr = result.getText();
			System.out.println("解析后内容:" + resultStr);
		} catch (IOException ioe) {
			System.out.println(ioe.toString());
		} catch (ReaderException re) {
			System.out.println(re.toString());
		}
	} catch (Exception ex) {
		System.out.println(ex.toString());
	}
}
 
源代码18 项目: RxTools-master   文件: ActivityScanerCode.java
private void initDialogResult(Result result) {
    BarcodeFormat type = result.getBarcodeFormat();
    String realContent = result.getText();

    if (rxDialogSure == null) {
        rxDialogSure = new RxDialogSure(mContext);//提示弹窗
    }

    if (BarcodeFormat.QR_CODE.equals(type)) {
        rxDialogSure.setTitle("二维码扫描结果");
    } else if (BarcodeFormat.EAN_13.equals(type)) {
        rxDialogSure.setTitle("条形码扫描结果");
    } else {
        rxDialogSure.setTitle("扫描结果");
    }

    rxDialogSure.setContent(realContent);
    rxDialogSure.setSureListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            rxDialogSure.cancel();
        }
    });
    rxDialogSure.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (handler != null) {
                // 连续扫描,不发送此消息扫描一次结束后就不能再次扫描
                handler.sendEmptyMessage(R.id.restart_preview);
            }
        }
    });

    if (!rxDialogSure.isShowing()) {
        rxDialogSure.show();
    }

    RxSPTool.putContent(mContext, RxConstants.SP_SCAN_CODE, RxDataTool.stringToInt(RxSPTool.getContent(mContext, RxConstants.SP_SCAN_CODE)) + 1 + "");
}
 
源代码19 项目: RipplePower   文件: UPCAReader.java
private static Result maybeReturnResult(Result result) throws FormatException {
	String text = result.getText();
	if (text.charAt(0) == '0') {
		return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
	} else {
		throw FormatException.getFormatInstance();
	}
}
 
@Override
public URIParsedResult parse(Result result) {
  String rawText = result.getText();
  if (!rawText.startsWith("MEBKM:")) {
    return null;
  }
  String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true);
  String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true);
  if (rawUri == null) {
    return null;
  }
  String uri = rawUri[0];
  return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null;
}