Reputation: 528
I'm using the camera and I have it in portrait mode for my app by
camera.setDisplayOrientation(90);
when the activity goes into the background and comes back the display orientation is back to 0 aka Landscape, but when I try to setDisplayOrientation(90) again it fails and throws an error (possibly because it is final).
How do I maintain the camera being in portrait aka 90degrees mode?
Also I have to support 2.2 and higher so I can only use API 8
Upvotes: 1
Views: 80
Reputation: 116
Per the Android API documentation, prior to API level 14 you are not allowed to set the orientation while preview is active: setDisplayOrientation() reference.
I'm guessing you need to call stopPreview()
, set the desired orientation, and then call startPreview()
.
Upvotes: 2
Reputation: 600
If you only want it to be portrait use the Manifest.xml file to declare the activity as portrait only in the activity tag put:
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation"
Upvotes: 0