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: 117
Registered: ‎02-12-2009
My Device: Not Specified

Device Orientation Observations - sublayout vs accelerometer sensor API

[ Edited ]

Hi All,


I have my app, all in  Portrait mode. Just in one screen I had requirement of handling Orientation and handle Landscape view.


I searched on forum and found some results of using sublayout to handle this. But it seems its not being called on tilt may be because I have forced app to be in Portrait mode.  Also sometimes sublayout called multiple times (on each addition of field in screen, when having phone in landscape orientation and then then opening app). While Accelerometer sensor listener is called on orientation change (using below code)


public void onData(AccelerometerData accData) {
	System.out.println("********************** Accleratometer called " +accData.getOrientation());
 public void register()
     // open channel
     Channel  orientationChannel = AccelerometerSensor.openOrientationDataChannel( Application.getApplication() );
    orientationChannel.setAccelerometerListener( this );
public void unregister()
{    // close the channel to save power

 But it seems as per java documentation "Subscribing to accelerometer sensor readings is costly for the device battery, and should therefore only be used only when necessary"


BB Simulator 9810, 9900 Observations


We have an API to check if Sensor is supported or not



Now this is returning true for both 9810, 9900. But orientation change listener is being called only for 9810 not for 9900. Is this isSupported method not related to orientation change?


9810 is touch screen portrait with physical slider keyboard, 9900 is Touch/Non touch Landcape phone with a physical non-slider keybpard. Is it like 9900 is already landcape mode and hence orientation change not triggered in this?


I couldn't test this on device yet. Please share if you have faced issues/related to orientation change.





 Edit : Reformatted code