Java Code Examples for com.google.zxing.Result#getText()
The following examples show how to use
com.google.zxing.Result#getText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaptureActivity.java From vmqApk with MIT License | 6 votes |
/** * 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(); }
Example 2
Source File: CaptureActivity.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 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(); }
Example 3
Source File: DecodeUtils.java From SimplifyReader with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: GenericMultipleBarcodeReader.java From barcodescanner-lib-aar with MIT License | 6 votes |
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; }
Example 5
Source File: CaptureActivity.java From QrCodeDemo4 with MIT License | 6 votes |
/** * 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(); }
Example 6
Source File: CaptureActivity.java From DoraemonKit with Apache License 2.0 | 6 votes |
/** * 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(); }
Example 7
Source File: URIResultParser.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
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; } }
Example 8
Source File: ZxingUtils.java From frpMgr with MIT License | 6 votes |
/** * 二维码解码 * * @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; }
Example 9
Source File: LoginActivity.java From Elephant with Apache License 2.0 | 6 votes |
@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); }
Example 10
Source File: GenericMultipleBarcodeReader.java From ZXing-Orient with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: UPCAReader.java From ZXing-Orient with Apache License 2.0 | 5 votes |
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(); } }
Example 12
Source File: ResultParser.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
protected static String getMassagedText(Result result) { String text = result.getText(); if (text.startsWith(BYTE_ORDER_MARK)) { text = text.substring(1); } return text; }
Example 13
Source File: HistoryItemAdapter.java From BarcodeEye with Apache License 2.0 | 5 votes |
@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; }
Example 14
Source File: BookmarkDoCoMoResultParser.java From weex with Apache License 2.0 | 5 votes |
@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; }
Example 15
Source File: QRCode.java From jeewx-api with Apache License 2.0 | 5 votes |
/** * 解析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()); } }
Example 16
Source File: ResultParser.java From barcodescanner-lib-aar with MIT License | 5 votes |
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); }
Example 17
Source File: ActivityScanerCode.java From RxTools-master with Apache License 2.0 | 5 votes |
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 + ""); }
Example 18
Source File: UPCAReader.java From RipplePower with Apache License 2.0 | 5 votes |
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(); } }
Example 19
Source File: BookmarkDoCoMoResultParser.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
@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; }
Example 20
Source File: ResultParser.java From ZXing-Orient with Apache License 2.0 | 5 votes |
protected static String getMassagedText(Result result) { String text = result.getText(); if (text.startsWith(BYTE_ORDER_MARK)) { text = text.substring(1); } return text; }