我正在尝试实现一个条形码阅读器。 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();
});
知道我做错了什么吗?
只需将其添加到您的 AndroidManifest.xml 文件中
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>
Blagojco,你明白了!!谢谢
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>