BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-22-2009, 09:47 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 9530
PIN: N/A
Carrier: Telus
Posts: 107
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Disable Accelerometer

Please Login to Remove!

Hello Everyone

Does anyone know how to disable AccelerometerSensor using code?

Thanks
Offline  
Old 06-23-2009, 03:38 PM   #2 (permalink)
Knows Where the Search Button Is
 
pfowler's Avatar
 
Join Date: May 2008
Location: Palo Alto, CA
Model: 8310
PIN: N/A
Carrier: ATT
Posts: 39
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default

I haven't done any accelerometer based programming, but here's the API:
BlackBerry JDE 4.7.0 API Reference: Class AccelerometerSensor

It appears that the accelerometer is disabled for an application until the app "registers" for it. Are you trying to disable it system wide?
Offline  
Old 07-27-2009, 03:41 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2009
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm also trying to disable the accelerometer system wide, I have an app that doesn't work ok when the device is rotated. Thanks!
Offline  
Old 07-27-2009, 11:54 AM   #4 (permalink)
Knows Where the Search Button Is
 
pfowler's Avatar
 
Join Date: May 2008
Location: Palo Alto, CA
Model: 8310
PIN: N/A
Carrier: ATT
Posts: 39
Post Thanks: 1
Thanked 0 Times in 0 Posts
Default

Disabling the accelerometer system wide would make your app a pretty bad citizen on the BB. I can't think of a case where this would be an acceptable use of the API - if this functionality were available. Why are you trying to disable it?

If your app doesn't work while rotated, don't register for accelerometer events.
Offline  
Old 07-27-2009, 12:28 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Actually, you do not have to register for accellerometer events for your app to rotate. This is built in to the UI on the Storm.

Anyway, I think the O.P. is not trying to disable this, he actually just wants to keep his app from laying out in landscape mode when the device is rotated.

TO keep the screen from rotating, you should use:

UiEngineInstance.setAcceptableDirections(int).

However, I should warn you that if the device is in landscape orientation when started, you cannot keep this first layout form happenning. Once the phone is rotated to Portrait mode, it will stay there.
Offline  
Old 09-08-2009, 02:52 AM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2009
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found a way to disable the accelerometer when using the basic MIDP classes and not RIM's API:

Code:
            DirectionControl dc =
                (DirectionControl) ((Controllable)Display.getDisplay(this)).
                    getControl("net.rim.device.api.lcdui.control.DirectionControl");
            int directions = DirectionControl.DIRECTION_PORTRAIT;
            dc.setAcceptableScreenDirections(directions);
            Display.getDisplay(this).setCurrent(newDisplay);
This code must be inserted just before setCurrent in the class that extends the Midlet class.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.