当前位置: 首页 > 知识库问答 >
问题:

众星二维码扫描仪自动关闭冲洗灯

高建本
2023-03-14

我集成了Zxing QR扫描仪库。这是我的应用程序/版本。格拉德尔

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    testCompile 'junit:junit:4.12'

    compile 'com.journeyapps:zxing-android-embedded:3.4.0'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}

onCreate()方法中,我有

mCameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
    try {
        cameraId = mCameraManager.getCameraIdList();
    } catch (CameraAccessException e) {
        Log.d("camera", "error");
    }
    setFlushLight(cameraId[0], true);

所以,当应用程序启动时,冲洗灯打开。然后我按下“启动QR扫描仪”按钮,启动QR扫描仪,我得到了预期的解析结果。

这是用于解析二维码的代码:

private IntentIntegrator qrScan;

//Getting the scan results
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    String latestScannedData;

    if (result != null) {
        if (result.getContents() == null) {
            //if qrcode has nothing in it
            Toast.makeText(this, "Result Not Found", Toast.LENGTH_LONG).show();
        } else {
            //if qr contains data
            latestScannedData = result.getContents();
            latestScannedTime = System.currentTimeMillis();
            if (latestScannedData.equals(previousData)) {
                //if this data equals previous data
                //tell to remove the card
                if (latestScannedTime - previousScanTime > n * 1000) {
                    //if last scan was more than n seconds ago
                    t1.speak("Please remove the card", TextToSpeech.QUEUE_FLUSH, null);
                    previousData = "";
                }
                qrScan.initiateScan();
            } else {
                t1.speak("Access granted", TextToSpeech.QUEUE_FLUSH, null);
                qrScan.initiateScan();
                previousData = latestScannedData;
                previousScanTime = System.currentTimeMillis();
            }
            Log.d("qrresult", result.getContents());
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

我的问题是:

ZXing QR扫描仪会自动关闭闪光灯(我的要求是在黑暗环境中扫描,因此必须有灯光)

我还发布了日志的一部分:

D/CameraPreview: resume()
D/CameraInstance: Opening camera
D/CameraInstance: Configuring camera
I/CameraManager: Camera Display Orientation: 90

I/CameraConfiguration: Requesting focus mode value from among: [auto]
I/CameraConfiguration: Supported focus mode values: [auto, infinity, fixed, macro, continuous-video, continuous-picture, manual]
I/CameraConfiguration: Can set focus mode to: auto
I/CameraConfiguration: Focus mode already set to auto
I/CameraConfiguration: Requesting flash mode value from among: [off]
I/CameraConfiguration: Supported flash mode values: [off, auto, on, torch]
I/CameraConfiguration: Can set flash mode to: off
I/CameraConfiguration: Flash mode already set to off
I/PreviewScalingStrategy: Viewfinder size: 1920x1080
I/CameraPreview: Starting preview
D/CameraInstance: Starting preview
D/OpenGLRenderer: endAllStagingAnimators on 0x55a98da7b0 (RippleDrawable) with handle 0x55a9894a00
I/AutoFocusManager: Current focus mode 'auto'; use auto focus? true

我怎样才能保持齐平灯打开?

共有1个答案

冯阳云
2023-03-14

IntentIntegrator包含手电筒的配置。但是这部分代码尚未发布,因此您必须使用来自master的快照构建。在所有已发布的版本上配置相机时,相机管理器似乎也会关闭手电筒灯。

在开始扫描之前,只需调用

qrScan.setTorchEnabled(true);

您甚至可以使用音量键控制火炬,此时up处于打开状态。

请注意,在任何扫描之后,焊炬可能会关闭,因此可能不要使用setFlushLight(cameraId[0],true)进行处理,只确保扫描从焊炬标志开始。

 类似资料:
  • 我正在尝试将Zstar二维码扫描仪与我的android webview应用程序集成。我成功导入了一个zstar项目并部署了它。扫描仪工作正常,没有任何问题。现在我正在尝试将此扫描仪与我的webview集成。 我正在研究的方案是,“当用户打开应用程序时,它应该启动webview,在webview中会有一个名为“扫描”的链接,单击该链接时,它应该向本机java代码“Zxing scanner func

  • 输出为: 输入字符串: WEWEW 输入模式搜索: 线程“main”java.util.NoSuchelementException:在java.util.scanner.nextline(scanner.java:1585) 在org.test.regtest.readline(regtest.java:39) 在org.test.regtest.main(regtest.java:22)

  • 我正在为平板电脑开发一个android应用程序(SynchroDigital iNOSP10-4.0 RES型号),我想使用ZXing库扫描包含字符串的QRcode。它会在我需要时启动扫描仪,但我无法扫描任何东西。 实际上,如果我直接使用条形码扫描仪应用程序,它甚至不起作用,黄色的点出现了,但什么也没有发生,无论亮度、距离或二维码的复杂性(尝试使用一个只包含字母“a”的巨大二维码),它都不会起作用

  • 我有一个简单的代码,计划扫描二维码并将值返回给用户: 现在我知道我需要将src/com.google.zxing.client.*文件夹放在这个项目的某个地方,但是在哪里?当我将其复制粘贴到我自己的src/文件夹时,它们都有错误,而这些错误在最初的Capureactive项目中并不存在。我该如何解决这个问题?

  • 我正在使用phonegap和JQM创建一个应用程序。我最近在我的应用程序上配置了条形码扫描仪。它工作得很好。但我有个问题。当我扫描二维码时,我不知道扫描完成后如何返回到我的应用程序。我安装了zxing库条形码扫描仪。

  • 问题内容: 我试图将我的应用程序中较大且经常使用的部分重构为单独的方法,以使其易于维护。 其中一些方法要求用户输入并进行输入验证,因此我使用了Scanner和System.in,但是当我关闭Scanner时,我也关闭了System.in。 所以我的问题是,我只能通过用CloseShieldInputStream屏蔽System.in来防止System.in关闭,还是应该开始将Scanner传递给方