How to force the Landscape / Landscape position? [duplicate]

0

How to force the Paiagem / Landscape position in my activity to always activate and lock the Portrait / Portrait position. I want my application to start in landscape position and not be able to turn to portrait position.

    
asked by anonymous 01.05.2018 / 03:39

2 answers

3

In your activity you need to put the following code in the onCreate method:

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);

Looking like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sua_activity);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
    
01.05.2018 / 03:50
1

Hello, this can also be done in AndroidManifest, not needing to do in the code:

    <activity
        android:name="..."
        android:label=".."
        android:configChanges="orientation"
        android:screenOrientation="portrait">
    
01.05.2018 / 16:02