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

Native Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 1
Registered: ‎02-29-2012
My Device: Playbook
My Carrier: none

Sensor issue in NDK 2.0

[ Edited ]

I am having a problem with the accelerometer data from sensor.h in ndk2.0. Here is an example of what I am trying to do:



sensor_set_skip_duplicates(SENSOR_TYPE_ACCELEROMETER, true);
sensor_set_rate(SENSOR_TYPE_ACCELEROMETER, 25 * 1000);
      bps_event_t *event;
      bps_get_event(&event, 0);
            if (event != NULL)
                  if (bps_event_get_domain(event) == (int16)sensor_get_domain()) //Must cast the domain in 16 bits as bps_event_get_domain() returns -1 and sensor_get_domain() returns 65535
        float x = 0.0f;
        float y = 0.0f;
        float z = 0.0f;
        sensor_event_get_xyz(event, &x, &y, &z); //FAILS HERE!
        printf("Accelerometer event: x %f y %f z %f\n", x, y, z);


I get the following error message when calling sensor_event_get_xyz():

[BPS:ERROR] Event passed into sensor get xyz is not part of the sensor domain.


When I do a hex print of bps_event_get_domain() vs sensor_get_domain() I get the following:

bps_event_get_domain() = 0xFFFF

sensor_get_domain() = 0xFFFFFFFF


It seems like one of these two returns the wrong integer size.

This seems specific to sensor.h as I had no problem with navigator.h


Thank you,

Posts: 38
Registered: ‎10-26-2011
My Device: BlackBerry Bold 9900
My Carrier: Rogers

Re: Sensor issue in NDK 2.0

To see an example project using the Accelerometer, open the Accelerometer example in the Momentics IDE under: File -> New -> Example.


Are you testing this on the Simulator?  The Simulator does not support the Accelerometer, you will need to test this with a real device.  You can get this information at runtime by using the sensor_is_supported() function.  You should always use this function before using the sensor BPS service.  You can see how to do this in the Accelerometer example project.


Are your Init() and Main_Loop() functions called from the same thread?  You need to call bps_initialize(), sensor_request_events() and all the related functions on the same thread that calls bps_get_event().  You would get -1 from either of the _get_domain() functions if bps_initialize() has not been called on that thread.


If you are using a beta version of NDK 2, I recommend using the final NDK 2.0 build which is now available.