我开发了一款android应用程序,可以扫描产品上的二维码。像Inigma这样的应用程序工作正常,但我的应用程序无法扫描

我开发了一款android应用程序,可以扫描产品上的二维码。像Inigma这样的应用程序工作正常,但我的应用程序无法扫描,android,2d,qr-code,zxing.net,Android,2d,Qr Code,Zxing.net,需要代码优化方面的帮助。我开发了一款android应用程序,可以扫描产品上标注的二维码 我已经测试了几个场景,其中其他应用程序(如Inigma)工作正常,但我的应用程序无法扫描:以下情况: 1)当我扫描在线生成的二维码时,我的应用程序和inigma都可以正常工作 .2)当我扫描瓶子等产品上打印的二维码时,我的应用程序无法扫描,但inigma扫描得非常完美 我落后在哪里?谁能帮帮我吗?在过去的一周里,我不得不尝试解决这个问题,但没有得到解决方案 技术细节:我正在使用ZXING库进行二维码扫描 请帮

需要代码优化方面的帮助。我开发了一款android应用程序,可以扫描产品上标注的二维码

我已经测试了几个场景,其中其他应用程序(如Inigma)工作正常,但我的应用程序无法扫描:以下情况:

1)当我扫描在线生成的二维码时,我的应用程序和inigma都可以正常工作

.2)当我扫描瓶子等产品上打印的二维码时,我的应用程序无法扫描,但inigma扫描得非常完美

我落后在哪里?谁能帮帮我吗?在过去的一周里,我不得不尝试解决这个问题,但没有得到解决方案

技术细节:我正在使用ZXING库进行二维码扫描


请帮忙(

尝试使用此方法,并在onResume()循环中调用该方法

private void initialiseDetectorsAndSources(){
//位图位图=((BitmapDrawable)getResources().getDrawable(R.drawable.ic_notfound)).getBitmap();
BarcodeDetector BarcodeDetector=新的BarcodeDetector.Builder(BarCodeScanActivity.this)
.setBarcodeFormats(条形码.所有_格式)
.build();
cameraSource=新建cameraSource.Builder(这是barcodeDetector)
.setRequestedPreviewSize(19201080)
.setFacing(摄像机源.摄像机面向后)
.setAutoFocusEnabled(true)//您应该添加此功能
.build();
surfaceView.getHolder().addCallback(新的SurfaceHolder.Callback()){
@凌驾
已创建的公共空隙表面(表面层表面层){
试一试{
if(ActivityCompat.checkSelfPermission(BarCodeScanActivity.this、Manifest.permission.CAMERA)
==PackageManager.权限(已授予){
开始(surfaceView.getHolder());
}否则{
ActivityCompat.requestPermissions(BarCodeScanActivity.this,新建
字符串[]{Manifest.permission.CAMERA},AppUtils.CAMERA_permission);
}
}捕获(IOE异常){
e、 printStackTrace();
}
}
@凌驾
公共无效表面更改(表面更改表面更改表面更改,int i,int i1,int i2){
}
@凌驾
公共空间表面已覆盖(表面层表面层){
}
});
条形码检测器.setProcessor(新检测器.Processor(){
@凌驾
公开无效释放(){
//Toast.makeText(BarCodeScanActivity.this,“为防止内存泄漏,条形码扫描仪已停止”,Toast.LENGTH_SHORT.show();
}
@凌驾
公共空隙接收检测(检测器。检测){
最终SparseArray条形码=检测。getDetectedItems();
if(条形码!=null&&barcodes.size()>0){
可用。post(新的Runnable(){
@凌驾
公开募捐{
字符串Scanda=条形码.valueAt(0).displayValue;
//Scanda是你的条形码
}
});
}
}
});
}

如果您发布一些相关的代码会更好!也许您应该更改您现在使用的库…:(我认为这个问题是由于库的准确性造成的。
private void initialiseDetectorsAndSources() {
//        Bitmap bitmap = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_notfound)).getBitmap();
        BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(BarCodeScanActivity.this)
                .setBarcodeFormats(Barcode.ALL_FORMATS)
                .build();

        cameraSource = new CameraSource.Builder(this, barcodeDetector)
                .setRequestedPreviewSize(1920, 1080)
                .setFacing(CameraSource.CAMERA_FACING_BACK)
                .setAutoFocusEnabled(true) //you should add this feature
                .build();

        surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
            @Override
            public void surfaceCreated(SurfaceHolder surfaceHolder) {
                try {
                    if (ActivityCompat.checkSelfPermission(BarCodeScanActivity.this, Manifest.permission.CAMERA)
                                                                                    == PackageManager.PERMISSION_GRANTED) {
                        cameraSource.start(surfaceView.getHolder());
                    } else {
                        ActivityCompat.requestPermissions(BarCodeScanActivity.this, new
                                String[]{Manifest.permission.CAMERA}, AppUtils.CAMERA_PERMISSION);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {

            }

            @Override
            public void surfaceDestroyed(SurfaceHolder surfaceHolder) {

            }
        });

        barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {
            @Override
            public void release() {
//                Toast.makeText(BarCodeScanActivity.this, "To prevent memory leaks barcode scanner has been stopped", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void receiveDetections(Detector.Detections<Barcode> detections) {
                final SparseArray<Barcode> barcodes = detections.getDetectedItems();

                if (barcodes != null && barcodes.size() > 0) {
                    available.post(new Runnable() {
                        @Override
                        public void run() {
                            String scandata = barcodes.valueAt(0).displayValue;
// the scandata is your barcode
                        }
                    });
                }
            }
        });
}