当前位置: 首页>>代码示例>>Java>>正文


Java BarcodeFormat.QR_CODE属性代码示例

本文整理汇总了Java中com.google.zxing.BarcodeFormat.QR_CODE属性的典型用法代码示例。如果您正苦于以下问题:Java BarcodeFormat.QR_CODE属性的具体用法?Java BarcodeFormat.QR_CODE怎么用?Java BarcodeFormat.QR_CODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.zxing.BarcodeFormat的用法示例。


在下文中一共展示了BarcodeFormat.QR_CODE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeFromTextExtras

private void encodeFromTextExtras(Intent intent) throws WriterException {
  // Notice: Google Maps shares both URL and details in one text, bummer!
  String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT));
  if (theContents == null) {
    theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT"));
    // Intent.EXTRA_HTML_TEXT
    if (theContents == null) {
      theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT));
      if (theContents == null) {
        String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
        if (emails != null) {
          theContents = ContactEncoder.trim(emails[0]);
        } else {
          theContents = "?";
        }
      }
    }
  }

  // Trim text to avoid URL breaking.
  if (theContents == null || theContents.isEmpty()) {
    throw new WriterException("Empty EXTRA_TEXT");
  }
  contents = theContents;
  // We only do QR code.
  format = BarcodeFormat.QR_CODE;
  if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT);
  } else if (intent.hasExtra(Intent.EXTRA_TITLE)) {
    displayContents = intent.getStringExtra(Intent.EXTRA_TITLE);
  } else {
    displayContents = contents;
  }
  title = activity.getString(R.string.contents_text);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:35,代码来源:QRCodeEncoder.java

示例2: encodeContents

private boolean encodeContents(String data, Bundle bundle, String type, String formatString) {
    // Default to QR_CODE if no format given.
    format = null;
    if (formatString != null) {
        try {
            format = BarcodeFormat.valueOf(formatString);
        } catch (IllegalArgumentException iae) {
            // Ignore it then
        }
    }
    if (format == null || format == BarcodeFormat.QR_CODE) {
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(data, bundle, type);
    } else if (data != null && data.length() > 0) {
        contents = data;
        displayContents = data;
        title = "Text";
    }
    return contents != null && contents.length() > 0;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:20,代码来源:QRCodeEncoder.java

示例3: encodeContentsFromZXingIntent

private boolean encodeContentsFromZXingIntent(Intent intent) {
    // Default to QR_CODE if no format given.
    String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
    try {
        format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
        // Ignore it then
        format = null;
    }
    if (format == null || BarcodeFormat.QR_CODE.equals(format)) {
        String type = intent.getStringExtra(Intents.Encode.TYPE);
        if (type == null || type.length() == 0) {
            return false;
        }
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(intent, type);
    } else {
        String data = intent.getStringExtra(Intents.Encode.DATA);
        if (data != null && data.length() > 0) {
            contents = data;
            displayContents = data;
            title = activity.getString(R.string.contents_text);
        }
    }
    return contents != null && contents.length() > 0;
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:26,代码来源:QRCodeEncoder.java

示例4: handleResult

@Override
public void handleResult(Result rawResult) {
    if ((rawResult.getBarcodeFormat() == BarcodeFormat.QR_CODE)) {
        if (onScannedListener.onScanned(rawResult.getText())) {
            return;
        } else {
            Toast.makeText(getActivity(), getString(R.string.send_qr_address_invalid), Toast.LENGTH_SHORT).show();
        }
    } else {
        Toast.makeText(getActivity(), getString(R.string.send_qr_invalid), Toast.LENGTH_SHORT).show();
    }

    // Note from dm77:
    // * Wait 2 seconds to resume the preview.
    // * On older devices continuously stopping and resuming camera preview can result in freezing the app.
    // * I don't know why this is the case but I don't have the time to figure out.
    Handler handler = new Handler();
    handler.postDelayed(new

                                Runnable() {
                                    @Override
                                    public void run() {
                                        mScannerView.resumeCameraPreview(ScannerFragment.this);
                                    }
                                }, 2000);
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:26,代码来源:ScannerFragment.java

示例5: build

public BarcodeGenerator build() {
    if (width <= 0) {
        throw new IllegalArgumentException("Width required");
    }
    if (height <= 0) {
        throw new IllegalArgumentException("Height required");
    }
    if (content == null) {
        throw new IllegalArgumentException("Content required");
    }
    if (mainColor == -1) {
        mainColor = DEFAULT_MAIN_COLOR;
    }
    if (emptyColor == -1) {
        emptyColor = DEFAULT_EMPTY_COLOR;
    }
    if (characterSet == null) {
        characterSet = DEFAULT_CHARACTER_SET;
    }
    if (barcodeFormat == null) {
        barcodeFormat = BarcodeFormat.QR_CODE;
    }

    return new BarcodeGenerator(width, height, mainColor, emptyColor, logo,
            content, characterSet, barcodeFormat, errorCorrection);
}
 
开发者ID:CoderChoy,项目名称:BarcodeReaderView,代码行数:26,代码来源:BarcodeGenerator.java

示例6: encode

public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) throws WriterException {
    if (contents.length() == 0) {
        throw new IllegalArgumentException("Found empty contents");
    } else if (format != BarcodeFormat.QR_CODE) {
        throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
    } else if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
    } else {
        ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
        int quietZone = 4;
        if (hints != null) {
            ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION);
            if (requestedECLevel != null) {
                errorCorrectionLevel = requestedECLevel;
            }
            Integer quietZoneInt = (Integer) hints.get(EncodeHintType.MARGIN);
            if (quietZoneInt != null) {
                quietZone = quietZoneInt.intValue();
            }
        }
        return renderResult(Encoder.encode(contents, errorCorrectionLevel, hints), width, height, quietZone);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:QRCodeWriter.java

示例7: onItemSelected

/**
 * Generates the chosen format from the spinner menu
 */
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    String compare = parent.getItemAtPosition(position).toString();
    if(compare.equals("AZTEC")){
        format = BarcodeFormat.AZTEC;
    }
    else if(compare.equals("QR_CODE")){
        format = BarcodeFormat.QR_CODE;
    }
}
 
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:13,代码来源:TextGeneratorActivity.java

示例8: encodeFromStreamExtra

private void encodeFromStreamExtra(Intent intent) throws WriterException {
  format = BarcodeFormat.QR_CODE;
  Bundle bundle = intent.getExtras();
  if (bundle == null) {
    throw new WriterException("No extras");
  }
  Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM);
  if (uri == null) {
    throw new WriterException("No EXTRA_STREAM");
  }
  byte[] vcard;
  String vcardString;
  try {
    InputStream stream = activity.getContentResolver().openInputStream(uri);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[2048];
    int bytesRead;
    while ((bytesRead = stream.read(buffer)) > 0) {
      baos.write(buffer, 0, bytesRead);
    }
    vcard = baos.toByteArray();
    vcardString = new String(vcard, 0, vcard.length, "UTF-8");
  } catch (IOException ioe) {
    throw new WriterException(ioe);
  }
  Log.d(TAG, "Encoding share intent content:");
  Log.d(TAG, vcardString);
  Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
  ParsedResult parsedResult = ResultParser.parseResult(result);
  if (!(parsedResult instanceof AddressBookParsedResult)) {
    throw new WriterException("Result was not an address");
  }
  encodeQRCodeContents((AddressBookParsedResult) parsedResult);
  if (contents == null || contents.isEmpty()) {
    throw new WriterException("No content to encode");
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:37,代码来源:QRCodeEncoder.java

示例9: decode

@Override
public final Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
    throws NotFoundException, ChecksumException, FormatException {
  DecoderResult decoderResult;
  ResultPoint[] points;
  if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
    BitMatrix bits = extractPureBits(image.getBlackMatrix());
    decoderResult = decoder.decode(bits, hints);
    points = NO_POINTS;
  } else {
    DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints);
    decoderResult = decoder.decode(detectorResult.getBits(), hints);
    points = detectorResult.getPoints();
  }

  // If the code was mirrored: swap the bottom-left and the top-right points.
  if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
    ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points);
  }

  Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
  List<byte[]> byteSegments = decoderResult.getByteSegments();
  if (byteSegments != null) {
    result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
  }
  String ecLevel = decoderResult.getECLevel();
  if (ecLevel != null) {
    result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
  }
  if (decoderResult.hasStructuredAppend()) {
    result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
                       decoderResult.getStructuredAppendSequenceNumber());
    result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY,
                       decoderResult.getStructuredAppendParity());
  }
  return result;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:37,代码来源:QRCodeReader.java

示例10: encode

@Override
public BitMatrix encode(String contents,
                        BarcodeFormat format,
                        int width,
                        int height,
                        Map<EncodeHintType,?> hints) throws WriterException {

  if (contents.isEmpty()) {
    throw new IllegalArgumentException("Found empty contents");
  }

  if (format != BarcodeFormat.QR_CODE) {
    throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
  }

  if (width < 0 || height < 0) {
    throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' +
        height);
  }

  ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
  int quietZone = QUIET_ZONE_SIZE;
  if (hints != null) {
    if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
      errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());
    }
    if (hints.containsKey(EncodeHintType.MARGIN)) {
      quietZone = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString());
    }
  }

  QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
  return renderResult(code, width, height, quietZone);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:34,代码来源:QRCodeWriter.java

示例11: encodeContentsFromZXingIntent

private boolean encodeContentsFromZXingIntent(Intent intent) {
   // Default to QR_CODE if no format given.
  String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
  format = null;
  if (formatString != null) {
    try {
      format = BarcodeFormat.valueOf(formatString);
    } catch (IllegalArgumentException iae) {
      // Ignore it then
    }
  }
  if (format == null || format == BarcodeFormat.QR_CODE) {
    String type = intent.getStringExtra(Intents.Encode.TYPE);
    if (type == null || type.isEmpty()) {
      return false;
    }
    this.format = BarcodeFormat.QR_CODE;
    encodeQRCodeContents(intent, type);
  } else {
    String data = intent.getStringExtra(Intents.Encode.DATA);
    if (data != null && !data.isEmpty()) {
      contents = data;
      displayContents = data;
      title = activity.getString(R.string.contents_text);
    }
  }
  return contents != null && !contents.isEmpty();
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:28,代码来源:QRCodeEncoder.java

示例12: decode

public final Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
        NotFoundException, ChecksumException, FormatException {
    DecoderResult decoderResult;
    ResultPoint[] points;
    if (hints == null || !hints.containsKey(DecodeHintType.PURE_BARCODE)) {
        DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints);
        decoderResult = this.decoder.decode(detectorResult.getBits(), (Map) hints);
        points = detectorResult.getPoints();
    } else {
        decoderResult = this.decoder.decode(extractPureBits(image.getBlackMatrix()), (Map)
                hints);
        points = NO_POINTS;
    }
    if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
        ((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points);
    }
    Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
            BarcodeFormat.QR_CODE);
    List<byte[]> byteSegments = decoderResult.getByteSegments();
    if (byteSegments != null) {
        result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
    }
    String ecLevel = decoderResult.getECLevel();
    if (ecLevel != null) {
        result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
    }
    if (decoderResult.hasStructuredAppend()) {
        result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, Integer.valueOf
                (decoderResult.getStructuredAppendSequenceNumber()));
        result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, Integer.valueOf
                (decoderResult.getStructuredAppendParity()));
    }
    return result;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:34,代码来源:QRCodeReader.java

示例13: onItemSelected

/**
 * Generates the chosen format from the spinner menu
 */
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    String compare = parent.getItemAtPosition(position).toString();
    if(compare.equals("AZTEC")){
        format = BarcodeFormat.AZTEC;
    }
    else if(compare.equals("CODABAR")){
        format = BarcodeFormat.CODABAR;
    }
    else if(compare.equals("CODE_128")){
        format = BarcodeFormat.CODE_128;
    }
    else if(compare.equals("CODE_39")){
        format = BarcodeFormat.CODE_39;
    }
    else if(compare.equals("EAN_13")){
        format = BarcodeFormat.EAN_13;
    }
    else if(compare.equals("EAN_8")){
        format = BarcodeFormat.EAN_8;
    }
    else if(compare.equals("ITF")){
        format = BarcodeFormat.ITF;
    }
    else if(compare.equals("PDF_417")){
        format = BarcodeFormat.PDF_417;
    }
    else if(compare.equals("QR_CODE")){
        format = BarcodeFormat.QR_CODE;
    }
    else if(compare.equals("UPC_A")){
        format = BarcodeFormat.UPC_A;
    }
}
 
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:37,代码来源:GenerateActivity.java

示例14: encodeFromTextExtras

private void encodeFromTextExtras(Intent intent) throws WriterException {
    // Notice: Google Maps shares both URL and details in one text, bummer!
    String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT));
    if (theContents == null) {
        theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT"));
        // Intent.EXTRA_HTML_TEXT
        if (theContents == null) {
            theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT));
            if (theContents == null) {
                String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
                if (emails != null) {
                    theContents = ContactEncoder.trim(emails[0]);
                } else {
                    theContents = "?";
                }
            }
        }
    }

    // Trim text to avoid URL breaking.
    if (theContents == null || theContents.isEmpty()) {
        throw new WriterException("Empty EXTRA_TEXT");
    }
    contents = theContents;
    // We only do QR code.
    format = BarcodeFormat.QR_CODE;
    if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
        displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    } else if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        displayContents = intent.getStringExtra(Intent.EXTRA_TITLE);
    } else {
        displayContents = contents;
    }
    title = activity.getString(R.string.contents_text);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:35,代码来源:QRCodeEncoder.java

示例15: onNothingSelected

@Override
public void onNothingSelected(AdapterView<?> parent) {
    format = BarcodeFormat.QR_CODE;
}
 
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:4,代码来源:VCardGeneratorActivity.java


注:本文中的com.google.zxing.BarcodeFormat.QR_CODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。