0

I want to lock the screen rotation, i.e. it should not rotate to landscape from portrait, even when I turn the device in ios and android.

The device should always be in portrait mode.

Please help how to solve this. Thanks.

user3666197
  • 1
  • 6
  • 50
  • 92
user2138675
  • 95
  • 1
  • 2
  • 12

4 Answers4

1

simply add android:screenOrientation="portrait" between every activity tags in your manifest

Fatih Santalu
  • 4,641
  • 2
  • 17
  • 34
  • is there a way to lock or hack an iPhone's orientation to portrait in mobile ios and android using CSS, HTML, Javascript or a combination there of? – user2138675 Oct 10 '14 at 06:41
0

iOS: In XCode you can go to your target and under Deployment Info uncheck everything except Portrait for device orientation.

In android: android:screenOrientation="portrait" in the activity tag in the manifest file

Sandro Machado
  • 9,921
  • 4
  • 36
  • 57
  • We are not using any manifest file.Can that be done using CSS or JS file?or else where do i need to add this code? – user2138675 Oct 09 '14 at 15:01
  • what tools are you using to develop the app? – Sandro Machado Oct 09 '14 at 15:08
  • We are using drupal and have used bootstrap 3 framework to develop the site.So we are using media queries for the devices like iphone,ipad or any android mobiles.Is there any way around?Please help. – user2138675 Oct 10 '14 at 05:57
  • We cannot do anything using the settings u mentioned above for ios.Same goes with android.We have only options to achieve this using CSS or JS or viewport in meta tag. – user2138675 Oct 10 '14 at 06:02
  • Please tell me some way using CSS, HTML, Javascript or a combination there of. – user2138675 Oct 10 '14 at 06:42
  • For iOS you can find more information here: http://stackoverflow.com/a/1207034/3482000 For Android try to use the size of the view to get the orientation. If the orientation is not portrait show a java script popup to the user change the orientation – Sandro Machado Oct 10 '14 at 09:05
0

add android:screenOrientation="portrait" to manifest

Brendan Henry
  • 99
  • 1
  • 9
0

for android put this in onCreate of all you activities setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);

  • is there a way to lock or hack an iPhone's orientation to portrait in mobile ios and android using CSS, HTML, Javascript or a combination there of? – user2138675 Oct 10 '14 at 06:42