Welcome!

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

Reply
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Screen orientation of a single screen - messed up after popping that screen.

Hi,

 

I have only one screen in my app that needs to be locked in Display.DIRECTION_NORTH orientation.

Other ones can be oriented in all directions.

 

After reading http://goo.gl/cXrhd I set the

Ui.getUiEngineInstance().setAcceptableDirections(allowedDirections);

 whenever a screen gets shown:

onUiEngineAttached(true){ 
oldAllowedDirections = X; // remember old orientation limit
setAcceptableDirections(newAllowedDirections);

 and that's also the moment I store previous screen allowed orientation.

 

This allows me to restore the orientation limit when a screen gets off the stack:

onUiEngineAttached(false){
 (oldAllowedDirections);
}

 

The logic works OK up until the point when the DIRECTION_NORTH screen gets popped off the stack.

The screen below it also gets the same orientation limit Smiley Sad

 

So setting the acceptable direction does work OK, but I cannot 'unset' it.

 

I would expect each screen to get its own acceptableDirections, and that they would be reset after each screen push, but it seems it just doesn't work that way :/

Any ideas?



"Listen carefully, I shall say this only once"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Screen orientation of a single screen - messed up after popping that screen.

as far as i know you can only set it for the whole application.
i would suggest to overwrite the layout of the screen, this way you can force it to stay as you want it, can't you?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Screen orientation of a single screen - messed up after popping that screen.

[ Edited ]

"Connected Limited Device Configuration (CLDC) applications should make the following call before any invocation of UiApplication.pushScreen()."
Nothing is being said about doing it only once for the app.
I bet if I change the orientation once again for my third screen, that last orientation limit would be applied to all screens.

Hmm...
If you could explain exactly how can layout be forced into portrait....
I know i can rework my calculations, but wouldn't fields be drawn in wrong directions?

Thank you for your input



"Listen carefully, I shall say this only once"
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen orientation of a single screen - messed up after popping that screen.

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Screen orientation of a single screen - messed up after popping that screen.

[ Edited ]

Yes, I saw that effort.
While its a bit different since I don't need to know when the change was made, rather just to force it for one single screen.
But I appreciate the reminder.
It is kinda strange how RIM imagined it.
For instance, if I get to the screen where I want portrait mode while I am tilted to landscape, the screen will be rendered in landscape (exactly matching your problem).

So this issue, in fact, has two parts
1) force desired orientation mode (for a given screen) - your post describes the problem in detail
2) lock the orientation for only a given screen.

One would think these two would actually be implemented as a whole Smiley Happy, and it (IMHO) does make absolute sense to think that way.

 

Edit: Of course, it all makes sense if RIM decided you can set acceptable orientation only once Smiley Happy

I am now hoping Simon's layout trick gets some follow up Smiley Happy ...



"Listen carefully, I shall say this only once"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Screen orientation of a single screen - messed up after popping that screen.

i have no ready-made solution, was only brainstorming, sorry Smiley Happy
as far as i know the screen re-layouts itself when the orientation changes, i thought if you block that re-layout you stay with the old one. won't help if you are in the wrong layout to start with though.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen orientation of a single screen - messed up after popping that screen.

I am not sure that the problem I fought and your situation are different.  In fact the problem I was trying to resolve was to get a single screen in landscape orientation.  When that screen was popped, I wanted the application back into portrait mode. 

 

As I understand, an orientation change does not take effect until

a) a new screen has been pushed

b) the device has been oriented into the direction requried

 

(b) is important, as I understand it - you can't get the device to layout in a new orientation until the device is actually in that orientation. 

 

In these circumstances, if you want a screen in a particular orientation and the device is not in that orientation, then I don't think you have any choice but to display a holding screen until the device is rotated.  Rotation will cause sublayout in the holding screen to be invoked and so you can check in there if the orientation is correct and, if so, dismiss the holding screen.

 

I don't know of any other application that does force a re-orientation of the device for a single screen, so I don't know if anyone else has found a more elegant solution. 

 

And yes, I think this is weakness in the API.   

 

 

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Screen orientation of a single screen - messed up after popping that screen.

Yup. On the spot. 

 

Thank you Peter.

 

I do have an idea, although I am not quite sure how nicely it can fit one's model (mine cannot swallow it):

 

You could make a separate app just for that screen. 

 

That way that app will have locked orientation mode and both problems get solved.

I already checked: if you start the app and lock the orientation mode before pushing, the screens will not enter any not allowed orientation mode. 

(One runs into problems we discussed only if he changes the acceptable orientation in midst two screen pushes).



"Listen carefully, I shall say this only once"
Developer
Posts: 38
Registered: ‎06-03-2009
My Device: 9800
My Carrier: Verizone

Re: Screen orientation of a single screen - messed up after popping that screen.

Hi I am new to this thread. I am also in need of Landscape mode for only one screen. The requirement is attached on the screen shot.

 post.JPG

You mentioned that on creating new application with landscape will solve this issue ?

 

How we can lnk two apps then ?

 

Thanks

Praveen K

Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Screen orientation of a single screen - messed up after popping that screen.

Hi Pravipravi,

As I mentioned, there is an 'ugly' workaround for this. You could create two UI applications, one in Portrait and one in Landscape layout.
How to start/sync those two applications is another topic you can browse for through the forums (search for: cross application communication).

Cheers...


"Listen carefully, I shall say this only once"