Listener orientation

I'm trying to understand how to write a listener orientation.  The documentation of the api do not have a very concrete example on how to do it.  Basically what I need to do, is change some field images according to what we in orientation.  What is the best way to create a listener for it.

Thank you.

It is not a listener to screen orientation changes.  The sample in the current 4.7.0 beta developer's guide is incorrect.  The sublayout method is called when an orientation change occurs, however, there are also other triggers for this method.

What you can do is to override this method and use the Display.getOrientation () method to check the orientation.  You'll need to follow the previous orientation in your application.  You can also call super.sublayout to trigger the behavior of default layout for the Manager.

I sent this update to our team of documentation for correction.

Tags: BlackBerry Developers

Similar Questions

  • How to listen for events from the Orientation

    In the process, when the events of the display orientation changes I need to do something, but I don't know how to get the change of Orientation event

    Please see this link

  • How can it ask i detect orientation any listener or event?

    Hi all

    Can anyone suggest me what method or event called when you change the orientation of the BB Strom Simulator.

    I can't figure how to detect when it changes from portrait to landscape to portrait and landscape.

    Please suggest any small code end or any idea you have successfully.

    Thanks in advance,


    sublayout() who is substituted by the display method will be called, not the sublayout() of each field method is called when the screen orientation changes.

    You can do something like this:

    public class TestScreen extends MainScreen
       public TestScreen()
       public void sublayout(int width, int height)
           //update scrren layout based on orientation
           if(Display.getOrientation()== Display.ORIENTATION_LANDSCAPE)
           else if(Display.getOrientation()== Display.ORIENTATION_PORTRAIT)
           super.sublayout(width, height);



  • Question about scaling for orientation landscape

    I noticed when you use the Simulator BB10, my app is scaling according to the reported resolution of 768 x 1280 instead of 1280 x 768. For this purpose the application is updated to be the incorrect scale. If the application is configured to start in landscape mode, the device should not report as such resolution (1280 x 768)?

    Is it possible to understand dynamically? or just assume if horizontal is reported to be smaller than the verticle, just trade accordingly?

    Hope you get what I mean, I probably not explains it very well

    Just because you specify landscape, the device will probably be in the corresponding mode. Default mode BB10's portrait and on Tablet, landscape.

    It is best to look just at the stage width and height to determine the current orientation and restore as needed. You can listen for orientation changes as well.

    If you run only in the landscape, then you will need to flip how your draw based on if app is landscape-aligned or not aligned it to landscape.

    You may be able to simply rotate your landscape drawable on a change of direction.

  • Orientation lock

    Is it possible to lock the orientation also listening to the events of orientation? If someone has a link to an example of code that would be much appreciated. I am trying to control a movieclip by rotation of the apparatus but keeping the locked application in landscape position fixed (as on iOS, you have the landscape with "home" button down and toward the top of the scenery... and you can stop its default behavior of shift between the two)

    Tests of change in direction in the Simulator turns out to be quite difficult because the current method to turn also triggers the Simulator to bring the menu apps (you get a thumbnail of the reduced application). It would do what I'm trying to do useless... so my another question is did anyone know if it is a real behavior of the device or a bug in the Simulator?

    Thank you

    While the change of orientation videos are few and far between (and not very informative) we can only assume that what we see in the Simulator is a bug and not the actual behavior of the device.

    I know that even with autoOrient set to false, apps always turns to using the method you said earlier. I would wait maybe until a more stable or peripheral sdk is in your hands to really test this. I know this isn't an ideal solution, but Mark has suggested that a new SDK is on its way (I hope that this week, but nobody knows.)

  • orientation of the screen from locking/unlocking code

    I know that we can lock the screen orientation by setting autoOrient false tag in the xml file.

    I want a certain vision in my application must be blocked to the landscape, while another view to lock on the portrait, and others without orientation lock. Is it possible to do? Or I have to manually manage it me via OrientationChangeEvent?

    Thank you

    AutoOrients is not something you can change during execution (unfortunately), so your only option is to allow it, listening for the orientationChange event and in some cases of preventDefault() on it.

    Peter is right, but the solution seems a bit more complicated than it should be, probably because it targeted AIR 2.5, where they took setOrientation() API for a reason any...

    If you target AIRT 2.7, stage.setOrientation () should be all you need to use to manually set the direction, IE when the view is loaded, you manually set the direction landscape and preventDefault on all the orientation changes. Then, when the view is dropped, you setOrientation() to what it was previously and allow events to pass by...

  • orientation BlackBerry storm


    is there a api / listener to follow the orientation of the device? who can inform us when device gets a rotation mode landscape to portrait mode, or vice versa.


    Please mark the thread as solved.

  • Orientation change not right when rotating rear

    Hi all

    I just found a problem when trying to listen to policy changes. I am using SDK 1.0.1 and test on a device with OS installed. I hope that I can make clear:

    If I rotate the camera 360 degrees in the same direction, everything works fine. However, when I change the direction things become messy.

    Say my current orientation is in position 1 and I rotate in a clockwise direction to position 2. 2 position, if I tilt left back to position 1 fires a change event, but it is not actually change the orientation. The orientation itself remains in position 2, but it raise an event for change as evidenced by a screen flash.

    Now, the machine always shows the 2 position, but the device itself is physically in position 1. I have to physically rotate to position 2 and then back to 1 to see the content according to position 1.


    In other words, to get this behavior, I need to run a device twice. First of all in all directions, then in the opposite direction.

    The operating system changes to the correct position. The scene registers an ORIENTATION_CHANGE or RESIZE event, but not a real change that remains in the same position.

    [/ Edit]

    I listened to StageOrientationEvent.ORIENTATION_CHANGE and Event.RESIZE scene with the same results.

    If I'm missing what is obvious, or is this a bug? I found in the incident handler.

    Code attached.

    Thanks in advance for any help.


        import flash.display.MovieClip;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import qnx.ui.text.Label;
        [SWF(backgroundColor = "#FFFFFF", frameRate = "30", width = "1024", height = "600")]
        public class OrientationTest extends MovieClip
            private var label:Label;
            public function OrientationTest()
                label = new Label;
                addEventListener(Event.ADDED_TO_STAGE, ready);
            private function ready(e:Event):void
                removeEventListener(e.type, arguments.callee);
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.addEventListener(Event.RESIZE, notify);
            private function notify(e:Event):void
                label.setSize(stage.stageWidth, stage.stageHeight);
                label.text = stage.orientation + ": " + stage.stageWidth + "x" + stage.stageHeight;

    InitialWindow descriptor XML:


    Found the culprit.

    In the application descriptor xml, the weirdness only happens when the renderMode is gpu:


    Set to auto or cpu works fine (auto by default cpu):




    I'm this deposit as a bug.

  • Navigation in AS3 OBJECT oriented programming Menu does not

    OK, so frame 1 in the timeline/layer, I have this code


    var btn1:MCButton = new MCButton();

    Btn1.x = 1048;

    Btn1.y = 300;

    Btn1.label_txt. Text = "play";

    addChild (btn1);

    Btn1.gotoAndStop (10);

    var btn2:MCButton = new MCButton();

    btn2.x = 1048;

    btn2.y = 380;

    btn2.label_txt. Text = "help";

    addChild (btn2);

    var btn3:MCButton = new MCButton();

    btn3.x = 1048;

    btn3.y = 460;

    btn3.label_txt. Text = "highscore";

    addChild (btn3);

    and now I have a MCButton class (.as)

    package {}

    import flash.display.MovieClip;


    SerializableAttribute public class extends MovieClip {} MCButton

    public void MCButton() {}

    manufacturer code #.


    this.buttonMode = true; a class film btn

    this.addEventListener (MouseEvent.MOUSE_OVER, sensitive); listen for a score event mouse

    this.addEventListener (MouseEvent.MOUSE_DOWN, down); listen for a mouse down event


    private void hover(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.addEventListener (MouseEvent.MOUSE_OUT, out);

    this.gotoAndStop (2);


    private void out(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OUT, out);

    this.addEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.gotoAndStop (1);


    private void down(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.addEventListener (MouseEvent.MOUSE_DOWN, down);

    this.gotoAndStop (3);




    OK so I want btn1 (which is in my diapers) to frame 10, where I have a different menu for 'easy', 'medium' "hard", I put btn1.gotoAndStop (10); but that doesn't seem to work, so I'm really confused on what im doing wrong.

    Please help me,

    Thank you.

    You can not remove sth. not created:

    removeChild (btn6);


    var btn6:MCButton = new MCButton();

    you try to remove btn6-9, before they were created

    I understand why you want to do, but you must make sure that the part to be removed is left side first.

    You can do this by ensuring that the button you are trying to delete is really there

    Change each line that removes sth. TO:


    removeChild (btn6);



    removeChild (btn7);




    Trying to set up a Navigation like this can not be considered good practice to OBJECT-oriented programming.

    That's why I said you should be aiming for a solution that does not rely on navigation of the timeline.

  • Event listener added EditText?


    I've got this following EditText called input_obj:

    var win, form;
    form = "dialog {  \
        orientation: 'column', \
        alignChildren: ['fill','top'], \
        preferredSize: [305, 300], \
        text: 'Form', \
        margins: 15, \
        input_group: Panel { \
            text: 'Number Options', \
            orientation: 'row', \
            alignChildren: ['fill','top'], \
            margins: 15, \
            input_obj: EditText { \
                text: '' \
            }, \
        } \
    win = new Window(form);

    How can I add a listener for events, so when the input value is changed, it performs a function?

    Thanks in advance!

    input_obj.onChange = function(){//you're code here
  • iOS device Orientation question

    I develop with AIR Flash CS5.5 3.1 overlay.

    I want to manage my rotating objects rather than to have AIR turn automatically.

    I put the auto orientation on/true, and I use the values of event.afterOrientation StageOrientationEvent.ORIENTATION_CHANGING in a switch/case statement to pass a string argument to my personalized orientation change handler. I also use preventDefault() to keep the AIR automatically turn the scene because my code is running my app.

    The application launches in portrait orientation / default and my custom rotation Manager works for all directions except when I try to rotate the iPad in portrait orientation / by default.

    This seems to be a bug? Why a change of orientation to portrait / by default would not fire a StageOrientationEvent.ORIENTATION_CHANGING event?

    Thanks for the clues that I'm on...

    It was easier than the accelerometer data tracking. Instead, I was able to read the value of stage.deviceOrientation using a timer of the half second and call my custom rotation functions based on the value. I still listen to change so that I can preventDefault() orientation.

  • How can I listen to an album in order?

    I can't find a way to turn off shuffle when you listen to an album.  I feel pretty stupid... I must be missing something * really * obvious.

    in OS X

    Shuffle on

    Shuffle off

    in OS 9.3.5 is this

  • I can't download any music for listening offline more

    All of a sudden, I can't download any music for offline listening more.

    Icon to download is available but when clicking top is transformed into a turning circle around and it stays like that... days.

    Do I did wrong?

    Thanks for the comments,


    Hi Peter Meylaerts.

    Welcome to the communities of Apple Support!

    We understand that you are no longer able to download music in Apple's music for the way you expect listen offline. We have a few different troubleshooting suggestions to suggest this behavior.

    First, we recommend that you close the application completely music. The following article explains this process:

    Force an application to close on your iPhone, iPad or iPod touch - Apple Support

    The music has been closed, restart your iPhone:

    Restart your iPhone, iPad or iPod touch - Apple Support

    If the problem persists, let us know if you experience this problem when you are connected to the Wi - Fi and cell phone. Have you noticed other issues with your iPhone on the network?

    See you soon!

  • Listen to concerto sequentially

    Problem: I want to listen to the Beethoven Concerto in 3 movements.    The program plays the first movement, but then moves to the 3rd movement or randomly selects another piece of music that I didn't.  I want to listen to the first movement, then the second movement, then the third movement.   This is impossible.   Any solution?

    Hey t5dashc,

    Thank you for being a part of the communities of Apple Support.

    I see your message you are trying to play your music in a sequential order, but it is up to chance.  This behavior is indicative of the shuffle option is enabled.  We will shuffle off in the music app and try to play the music again:

    When you play a song, you see a player at the bottom of the screen. You can continue to browse other titles to find the next perfect song.

    Press or drag upward on the drive down to see the current reading and controls screen.

    Then stir and repeat

    Also on the playing screen, you can go back, put in pause or fast forward a song, control volume, playback of the song, lyricsand more.

    Swipe up on reading to display your queue up next, that lists all the songs that you have selected for the current playback.

    Drag the songs with to rearrange the order, or swipe to the left to remove a song you want to ignore.

    Press on to the right of the next place to mix the songs in a playlist or album.

    Type once to play entire playlist or album looped or twice to repeat a song. Type a third time to remove the repetition.

    Use of music music Apple in the app

    Take care.

  • Why do I may for listening to my own music?


    My daughter has an iPad, where she purchased songs in iTunes.

    She wants to listen to these songs also on his phone of Samsung.

    When she tries to download music from Apple app store Google play, she needs to buy a subscription to Apple's music to listen to the songs that she has already bought from iTunes.

    If this is the case, Apple is in charge it twice for the music she wants to hear.

    I hope that we have misunderstood the situation and that Apple can explain how she can listen to the music she bought in iTunes.

    Thank you very much in advance for the advice.

    With sincere friendships.


    Apple music ≠ iTunes! Apple music is apples service - subscription streaming will not get access to the music you already own, but millions of other songs as well.

    What you are looking for is how to get the music purchased from iTunes on your Android phone. This, still once, ha nothing to do with music from Apple. Maybe this web page (and many others like him, just google for it) can help you: .html



Maybe you are looking for