Android 中的 Zxing 始终处于横向模式

问题描述 投票:0回答:2

我正在尝试实现一个条形码阅读器。 https://www.youtube.com/watch?v=wfucGSKngq4&list=PLYBH5YZZegIf1DzLtuFmeDFqHYsfw1h1I&index=7&t=232s 我已经遵循了这个教程,几乎一切都工作正常。我唯一的问题是它总是以横向屏幕打开,我完全不知道我做错了什么。

butonScanare.setOnClickListener(v -> {
        IntentIntegrator integrator = new IntentIntegrator(activity);
        integrator.setCaptureActivity(CaptureActivity.class);
        integrator.setOrientationLocked(false);
        integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
        integrator.setPrompt("Scanare");
        integrator.initiateScan();
    });

知道我做错了什么吗?

java android zxing
2个回答
2
投票

只需将其添加到您的 AndroidManifest.xml 文件中

   <activity
            android:name="com.journeyapps.barcodescanner.CaptureActivity"
            android:screenOrientation="portrait"
            tools:replace="android:screenOrientation"
            android:stateNotNeeded="true"/>

0
投票

Blagojco,你明白了!!谢谢

 <activity
        android:name="com.journeyapps.barcodescanner.CaptureActivity"
        android:screenOrientation="portrait"
        tools:replace="android:screenOrientation"
        android:stateNotNeeded="true"/>
© www.soinside.com 2019 - 2024. All rights reserved.