Question: I've `MainActivity.kt` where I show different fragments for different needs. At some point, I press button 'X' that calls `startScanner()` function:

```
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'

```

It does open scanner and everything, but in **landscape mode**. 

Why is this not working?

Answer: 
There is a shortcut to do this. Just add this to the manifest:

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

```
You can set the orientation programmatically (in your activity):

[ActivityInfo.SCREEN\_ORIENTATION\_LANDSCAPE](http://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_LANDSCAPE)

```
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

```

[ActivityInfo.SCREEN\_ORIENTATION\_PORTRAIT](http://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_PORTRAIT)

```
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

```