1
votes

I want to force one special activity of my project (target sdk 17-19) to be displayed in portrait mode.

To that effect, I placed:

  • setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) in the onCreate event of my class,
  • and android:configChanges="orientation|screenSize" in the activity section of my AndroidManifest.xml.

This works fine with my emulator.

I have to do it programmatically, because the user should decide which orientation should be used for this single activity.

On my target device (HP Slate 21, Android 4.2.2, no sensor available) my activity is displayed in portrait mode without rotating the screen, which means there are black bars on the left and right side of my view, though the device is still in landscape mode.

The device is in landscape, but the view is in portrait. In the emulator, the device is in landscape, and the view is in landscape. What could be the reason?

2
u can set the orientation property of activity to portrait in androidmanifest.xml itself will let u to use your activity to stay in poratit modeCoolMonster

2 Answers

1
votes

This is an issue related to the HP 21 / HP 21 Pro. Their emulated orientation is not based on an emulated device and done by software hook. Testing your setting on tablets will show that your code works propperly.

0
votes
 <activity android:name=".YourActivity"
            ....
              android:screenOrientation="portrait">

this will help you.