how to get orientation lock to portrait android stackoverflow

Java
 <activity
            android:name="com.example.demo_spinner.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
Source

Also in Java: