I'm developing an Android application, and I don't like it to rotate when the user rotates the screen. The user will be able to use only the portrait view, but not the landscape one.
            Asked
            
        
        
            Active
            
        
            Viewed 7,781 times
        
    0
            
            
         
    
    
        Peter Mortensen
        
- 30,738
- 21
- 105
- 131
 
    
    
        KrithGhosh
        
- 88
- 1
- 5
- 
                    did you try to set Orientation in manifest? – Madhu Jul 02 '15 at 11:24
- 
                    The right answer here: https://stackoverflow.com/a/6637075/1034622 – Pablo Chvx Dec 15 '17 at 23:26
5 Answers
16
            
            
        Put the following in your manifest, in every activity that should not rotate:
<activity
    ...
    android:screenOrientation="portrait" />
 
    
    
        Peter Mortensen
        
- 30,738
- 21
- 105
- 131
 
    
    
        Hans1984
        
- 796
- 11
- 24
- 
                    myApp.Animate().Rotate(360).Duration(5000).Start(); Hahahahaha. Still rotate. – nyconing May 08 '18 at 09:00
- 
                    
2
            
            
        Add this below code in your activity from AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YourPackage.name">
    //Other Activities and Intents
    <activity
        //Other lines of your activity code
        android:screenOrientation="portrait">
    </activity>
</manifest>
Tell me if I helped you and good programming!
PD: Next time searches a little in this community or in Internet, because it's a typical question and you can find a lot of answers from this and others problems, thanks!
 
    
    
        Merlí Escarpenter Pérez
        
- 2,569
- 3
- 26
- 49
2
            
            
        You have to declare all the limitations/permissions in your manifest file. Just add the following permission for your application.
android:screenOrientation="portrait"
 
    
    
        Peter Mortensen
        
- 30,738
- 21
- 105
- 131
 
    
    
        Esha
        
- 76
- 1
- 8
1
            
            
        In your manifest, in the activity tag, use:
android:screenOrientation="portrait"
 
    
    
        Peter Mortensen
        
- 30,738
- 21
- 105
- 131
 
    
    
        Ahmed Basyouny
        
- 343
- 3
- 11
0
            
            
        Add in manifest android:screenOrientation to your app.
<activity android:name="YourActivity" android:screenOrientation="portrait" > (...) </activity>
 
    
    
        krystian71115
        
- 1,927
- 17
- 36