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

Regular Contributor
Posts: 81
Registered: ‎01-16-2012
My Device: BOLD 9650 + developer
My Carrier: Vodafone

landscape and portrait mode in blackberry os 6

how can i detecet the land scape and protrate onece it habben to change the images resolution

Posts: 59
Registered: ‎05-06-2012
My Device: Blackberry torch 9850
My Carrier: Voila

Re: landscape and portrait mode in blackberry os 6

[ Edited ]

Hello amr3434,

I was in your issued and I think the API provides no method to do this.

As suggestion depending on your application needs, you may try one of this method as each  of them have their own deadvantage.


1) Look display rotation mode in the main method of your application or give the user the possibility for change it himself.

The code will look like this :

(the orientation will not update automatically anymore)

int directionID= Display.getOrientation();
UiEngineInstance engine= Ui.getUiEngineInstance();

//(possibles directions are :Display.ORIENTATION_LANDSCAPE, Display.ORIENTATION_PORTRAIT)


2) create a new thread to check if the display rotation changed to update the UI:

(use the cpu as long you want to update the UI)

class DspCheck extends Thread{
    int currentOrientation= Display.getOrientation();
    public void run(){
            if( currentOrientation != Display.getOrientation() ){
                currentOrientation= Display.getOrientation();
            try {
                // sleep for a little while to control cpu usage/
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block

Hope iIve help,



I always love and appreciate feedback .

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: landscape and portrait mode in blackberry os 6

While there is no specific API, the intention is that you will detect this change in the same place you check other layout changes, i.e. sublayout().  Probably the easiest option is to have a sublayout() override for your Screen and in there detect the orientation change and update the images you use accordingly   Look for other Threads that discuss tilt for more information on this.


I would give you more here but in fact there are other devs on this forum who are better at this than me, so hopefully you will get a better answer from one of them if you wait a bit. 


One thing I will say is that you can rearrange your existing Fields, but you can't do anything that would require a new layout.  So for example, you can adjust the images you are displaying in your BitmapField, but you can't add a new BitmapField. If you want to remove and add Fields to process the orientation change you can use an issue an invokeLater, and do the repopulating in that processing.  Hope that makes sense.