我有MainActivity.kt,在那里我展示了不同需求的不同片段.在某些时候,我按下调用startScanner()函数的按钮’X’:
- private fun startScanner() {
- IntentIntegrator(this)
- .setOrientationLocked(false)
- .setPrompt("SCANNING?")
- .initiateScan()
- }
的Manifest.xml:
- <activity
- android:name=".MainActiity"
- android:theme="@style/AppTheme"
- tools:replace="android:screenOrientation"
- android:stateNotNeeded="true"
- android:screenOrientation="fullSensor"
- android:windowSoftInputMode="stateHidden" />
Gradle.file:
- compile 'com.journeyapps:zxing-android-embedded:3.6.0'
它确实打开扫描仪和一切,但在横向模式.
为什么这不起作用?
解决方法
有一个快捷方式可以做到这一点.只需将其添加到清单:
- <activity
- android:name="com.journeyapps.barcodescanner.CaptureActivity"
- android:screenOrientation="portrait"
- tools:replace="android:screenOrientation"
- android:stateNotNeeded="true"/>