类com.google.zxing.activity.CaptureActivity源码实例Demo

下面列出了怎么用com.google.zxing.activity.CaptureActivity的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: QrCodeLib   文件: DecodeThread.java
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

    this.activity = activity;
    handlerInitLatch = new CountDownLatch(1);

    hints = new Hashtable<DecodeHintType, Object>(3);

    if (decodeFormats == null || decodeFormats.isEmpty()) {
        decodeFormats = new Vector<BarcodeFormat>();
        decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

    if (characterSet != null) {
        hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
源代码2 项目: QrCodeLib   文件: MainActivity.java
private void startQrCode() {
    // 申请相机权限
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission
                .CAMERA)) {
            Toast.makeText(this, "请至权限中心打开本应用的相机访问权限", Toast.LENGTH_SHORT).show();
        }
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, Constant.REQ_PERM_CAMERA);
        return;
    }
    // 申请文件读写权限(部分朋友遇到相册选图需要读写权限的情况,这里一并写一下)
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission
                .WRITE_EXTERNAL_STORAGE)) {
            Toast.makeText(this, "请至权限中心打开本应用的文件读写权限", Toast.LENGTH_SHORT).show();
        }
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constant.REQ_PERM_EXTERNAL_STORAGE);
        return;
    }
    // 二维码扫码
    Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
    startActivityForResult(intent, Constant.REQ_QR_CODE);
}
 
源代码3 项目: vmqApk   文件: MainActivity.java
public void startQrCode(View v) {
    // 申请相机权限
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, Constant.REQ_PERM_CAMERA);
        return;
    }
    // 申请文件读写权限(部分朋友遇到相册选图需要读写权限的情况,这里一并写一下)
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constant.REQ_PERM_EXTERNAL_STORAGE);
        return;
    }
    // 二维码扫码
    Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
    startActivityForResult(intent, Constant.REQ_QR_CODE);
}
 
源代码4 项目: vmqApk   文件: DecodeThread.java
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

  this.activity = activity;
  handlerInitLatch = new CountDownLatch(1);

  hints = new Hashtable<DecodeHintType, Object>(3);

  if (decodeFormats == null || decodeFormats.isEmpty()) {
  	 decodeFormats = new Vector<BarcodeFormat>();
  	 decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
  }
  
  hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET, characterSet);
  }

  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
源代码5 项目: QrCodeDemo4   文件: MainActivity.java
private void startQrCode() {
    // 申请相机权限
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, Constant.REQ_PERM_CAMERA);
        return;
    }
    // 申请文件读写权限(部分朋友遇到相册选图需要读写权限的情况,这里一并写一下)
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        // 申请权限
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constant.REQ_PERM_EXTERNAL_STORAGE);
        return;
    }
    // 二维码扫码
    Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
    startActivityForResult(intent, Constant.REQ_QR_CODE);
}
 
源代码6 项目: QrCodeDemo4   文件: DecodeThread.java
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

  this.activity = activity;
  handlerInitLatch = new CountDownLatch(1);

  hints = new Hashtable<DecodeHintType, Object>(3);

  if (decodeFormats == null || decodeFormats.isEmpty()) {
  	 decodeFormats = new Vector<BarcodeFormat>();
  	 decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
  }
  
  hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET, characterSet);
  }

  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
源代码7 项目: CodeScaner   文件: MainActivity.java
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == Constant.REQ_QRCODE && data != null) {
        byte[] result = data.getByteArrayExtra(CaptureActivity.KEY_RESULT);
        if (result == null || result.length == 0) {
            tvReuslt.setText("");
            btnCopy.setVisibility(View.GONE);
            return;
        }
        String payCode = new String(result);
        tvReuslt.setText(payCode);
        btnCopy.setVisibility(View.VISIBLE);
    } else {
        tvReuslt.setText("");
        btnCopy.setVisibility(View.GONE);
    }
}
 
源代码8 项目: QrCodeLib   文件: CaptureActivityHandler.java
public CaptureActivityHandler(CaptureActivity activity, Vector<BarcodeFormat> decodeFormats,
                              String characterSet) {
    this.activity = activity;
    decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
            new ViewfinderResultPointCallback(activity.getViewfinderView()));
    decodeThread.start();
    state = State.SUCCESS;
    // Start ourselves capturing previews and decoding.
    CameraManager.get().startPreview();
    restartPreviewAndDecode();
}
 
源代码9 项目: vmqApk   文件: CaptureActivityHandler.java
public CaptureActivityHandler(CaptureActivity activity, Vector<BarcodeFormat> decodeFormats,
                              String characterSet) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;
  // Start ourselves capturing previews and decoding.
  CameraManager.get().startPreview();
  restartPreviewAndDecode();
}
 
源代码10 项目: QrCodeDemo4   文件: CaptureActivityHandler.java
public CaptureActivityHandler(CaptureActivity activity, Vector<BarcodeFormat> decodeFormats,
                              String characterSet) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;
  // Start ourselves capturing previews and decoding.
  CameraManager.get().startPreview();
  restartPreviewAndDecode();
}
 
源代码11 项目: CodeScaner   文件: MainActivity.java
private void getPermission() {
    //第二个参数是需要申请的权限
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        //权限还没有授予,需要在这里写申请权限的代码
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 2);
    } else {
        //权限已经被授予,在这里直接写要执行的相应方法即可
        startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class), Constant.REQ_QRCODE);
    }
}
 
源代码12 项目: CodeScaner   文件: MainActivity.java
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == 2) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class), Constant.REQ_QRCODE);
        } else {
            // Permission Denied
            Toast.makeText(MainActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show();
        }
    }
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
源代码13 项目: QrCodeLib   文件: DecodeHandler.java
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
 
源代码14 项目: vmqApk   文件: DecodeHandler.java
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
源代码15 项目: QrCodeDemo4   文件: DecodeHandler.java
DecodeHandler(CaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
  multiFormatReader = new MultiFormatReader();
  multiFormatReader.setHints(hints);
  this.activity = activity;
}
 
 类所在包
 同包方法