Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 22
Registered: ‎04-09-2010
My Device: Storm
My Carrier: Just developing

Re: Storm Orientation Layout Problem

I'm fairly new to blackberry programming (but not Illiterate).

I have an app with lots of screens. Some of them need to have a fixed orientation depending on a bitmap's size chosen on the first screen. The same screens might even have different orientations on the lifetime of the app, because I can pop back to the first screen and choose another bitmap.

I'm using the 5.0 environment and the Storm (9550) emulator. The provided example (thanks keean) does work for the first screen.
Unfortunately, subsequent screens don't seem to regard this setting. I have created a getScreen method on my main class that controls all the screen pushing and popping. The following code tries to control the allowed directions for 4 screens that need it.:

int directions;
if ((screenIndex == Config.SCREEN_SHOW_SCENE) ||
    (screenIndex == Config.SCREEN_SELECT_PIC_CAMERA) ||
    (screenIndex == Config.SCREEN_EDIT) ||
    (screenIndex == Config.SCREEN_DONE))
    if (image.getWidth() > image.getHeight())
        directions = Display.DIRECTION_LANDSCAPE;
        directions = Display.DIRECTION_PORTRAIT;



After this code I create the screen and push it on the screen stack. The direction of the screen is unaffected. After I rotate the simulator, the direction setting kicks in.
Also tried with DIRECTION_NORTH, EAST and WEST, to no avail.

I'm forced to rework the app to allow for any orientation, always listening to orientation changes to adjust the layout. This is far from ideal.

I could "force" the user to rotate the screen, but this is not reasonable.

I could also use drawTexturePath to rotate the elements on the screen, but although it is very fast, it would for force me to take care of all the layout of the screen's elements.


I hope that in a future release I'll be able to control direction as I see fit.

Posts: 22
Registered: ‎04-09-2010
My Device: Storm
My Carrier: Just developing

Re: Storm Orientation Layout Problem

I would also like to know how do I know which direction is currently active. I can use Display.getOrientation(), but that only returns Orientation (landscape, portrait), not direction (north, east, west).

New Contributor
Posts: 3
Registered: ‎03-29-2010
My Device: none
My Carrier: none

Re: Storm Orientation Layout Problem

If all you want is to lock the orientation to either Landscape or Portrait, and never want to unlock it, then I found that the following trick will work.


Within the class that extends UiApplication, but before pushing any sceens to the stack :





Because the application return to the foreground with the screen locked it will render all screens in the locked orientation.


BE WARNED, this should only be done before screens are pushed to the stack or else the application will become unstable and will usually crash shortly after.



Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: Storm Orientation Layout Problem

how has this been a 2 year problem and still no suitable solution?