0

My app stops from working for some reason when the phone is rotated to the side and so the app does too. How can I avoid this, making it so it appears only vertically? Thanks a lot

  • Your app crashes because you have a bug. Your first response should *not* be to hide the error, but to find your bug and fix it. – Kevin Coppock Aug 29 '14 at 20:44
  • It's a good question if the bug part is taken out. – allen1 Aug 29 '14 at 20:48
  • I disagree; several duplicates should have come up in a search, such as http://stackoverflow.com/questions/13569052/locking-the-screen-to-landscape-for-only-one-activity or http://stackoverflow.com/questions/2730855/prevent-screen-rotation-android – Kevin Coppock Aug 29 '14 at 20:50
  • I have no idea what the bug is. Why is it only if app screen is rotated? I use too many textfield, one after another and vertically it is shown ok, maybe horizontally can't fit to the screen and causes crush? –  Aug 29 '14 at 20:50
  • When configuration changes, the app starts over. But as mentioned above, you should fix the bug first that causes the crash – Eenvincible Aug 29 '14 at 21:00
  • and I just tested it on the emulator and it orients fine, wtf :/ –  Aug 29 '14 at 21:15
  • @darkchampionz Look at your logs. Any crash will have a stack trace. Find that trace, and see there what the error is. It will tell you exactly what line of code caused the error, and why. – Kevin Coppock Aug 29 '14 at 21:36

2 Answers2

1

add this to your activities in android manifest :)

android:screenOrientation = "portrait">

Here is a full example:

<activity 
   android:name=".Activity.MainActivity" 
   android:label="@string/app_name" 
   android:screenOrientation="portrait">
</activity>
apmartin1991
  • 3,064
  • 1
  • 23
  • 44
-1

In your app's manifest file, set activity to be vertical... Its easy...

  • According to [Android Activity Element](http://developer.android.com/guide/topics/manifest/activity-element.html), `vertical` is not a choice. Can you provide a reference? – jww Aug 30 '14 at 00:13