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
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Accelerometer issue..

I know this would not be the place to report hardware issue, but I was just wondering if anyone else has had a similar issue. In all of my applications, when I query the device orientation, I am getting unknown orientation regardless of how it is oriented. I had the same issue on my S1 after about 6 months of use, but I had dropped it several times and just chalked it up to being dropped. However, I have never dropped my S2 and also, when I upgraded the OS to 5.0 on the S1, the issue went away. Just wondering if anyone knew why it would give unknown or has seem the same thing? Here is the code I use to check the orientation:

 

 

if( AccelerometerSensor.isSupported() ){
   Channel dataChannel = AccelerometerSensor.openOrientationDataChannel(getApplication());

   int orientation = dataChannel.getOrientation();
   Resources.Resources.orientation = orientation;
   dataChannel.close();
   dataChannel = null;

   System.out.println();

   if( (orientation == AccelerometerSensor.ORIENTATION_LEFT_UP) ){
      Ui.getUiEngineInstance().setAcceptableDirections( DirectionControl.DIRECTION_WEST );
   } else if( (orientation == AccelerometerSensor.ORIENTATION_RIGHT_UP) ){
      Ui.getUiEngineInstance().setAcceptableDirections( DirectionControl.DIRECTION_EAST );
   } else {
            Ui.getUiEngineInstance().setAcceptableDirections( DirectionControl.DIRECTION_NORTH );
   }
}

 

 

Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Accelerometer issue..

OS version(s)?

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Accelerometer issue..

All of the official OS versions for Verizon for the S1 and S2. I don't know them off-hand.