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
Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Restrict screen from going to landscape mode

Hi all,

I have an app with so many screens out of which, 1 screen is like main screen of the app, and i don't want that screen to shift to landscape mode though i rotate the device, it should remain in the portrait mode always..

Is there a way to do this!!!

Please let me knw!!!

 

Thnx..

$@/\/\!!!
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: Restrict screen from going to landscape mode

hi,
use this code for that class

import net.rim.device.api.ui.UiEngineInstance;// comment for 4.5

in constructor, write this code and check wether it works
// comment for 4.5
try{
UiEngineInstance _ue = Ui.getUiEngineInstance();
_ue.setAcceptableDirections(Display.DIRECTION_NORTH);
}catch(Exception e){}
//

Thanks & Regards
pp
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: Restrict screen from going to landscape mode

Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Re: Restrict screen from going to landscape mode

Hey thnx,

But this is not working in my code,

I am using OS 5.0 and 6.0,

If i use the above code then it shows all the screens in portrait mode, but i just want to show a single screen in portrait mode and all other should behave normally depending on directions..

If u have any code sample in which this is working then please let me know.

Thnx..

$@/\/\!!!
Developer
Aman_vivek
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520

Re: Restrict screen from going to landscape mode

Hi,

 

add below single line code in constructor of that screen which you want to fix.

 

Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT);

 

I hope this will slove your issue

Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Re: Restrict screen from going to landscape mode

I have already tried this but this is also having the same problem, it reflects for all the screens and all the screens are shown in portrait mode..

$@/\/\!!!
Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Re: Restrict screen from going to landscape mode

can we set PORTRAIT mode for a particular screen using that screens object or instance??

$@/\/\!!!
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: Restrict screen from going to landscape mode

Hi,
check this, this is not the result but just to know.
http://supportforums.blackberry.com/t5/Java-Development/Storm-Orientation-Layout-Problem/td-p/98400/...

I have check many thread but all those are for application screen orientation not for particular screen.

so set the orientation before screen push for all the screen and check whether works.

Thanks & Regards
pp
Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Re: Restrict screen from going to landscape mode

ohhk.. will try.. thnx!!!

$@/\/\!!!
Contributor
sameerbelsare
Posts: 44
Registered: ‎01-12-2011
My Device: storm

Re: Restrict screen from going to landscape mode

Hi PP,

I tried above thing,

In one class (in which i want portrait mode), i wrote  Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT);

and in another class i wrote

Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_LANDSCAPE);

But when it goes to that class it sets the mode for whole app, that means when i push 1st screen the PORTRAIT mode is set for all screens and when i push the second screen the LANDSCAPE mode is set for all screens i.e for whole app..

nyways, thnx for your help, If you find anything please let mo know..

thnx a lot..

$@/\/\!!!