Connection of the accelerometer

Dear all,

I am writing a progrma that make use of the accelerometer to detect the orientation of the screen.

The structure of my program is as below:

I have a class call 'ABC', that the main function is in this class. In the main function, I use the pushscreen command to push the screen of another class 'DEF '. And I want to exec the acceleormeter in the class "DEF". If I use the command to open a connection to the accelerometer but it always return a null value.  I can't open the accelerometer and detect the orientation of the screen.

Here is my code:

Class ABC:

import net.rim.device.api.applicationcontrol.ApplicationPermissions;
import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;

public class ABC extends UiApplication      //ABC class
{
    public static void main(String[] args)
    {
        /*Create a new thread of the application and make the currently
        running thread the application's event dispatch thread*/
        ABC app = new ABC();
        app.enterEventDispatcher();
    }

    //Constructor
    public ABC()
    {
        pushScreen(new DEF());
    }
}       //End of ABC

Class DEF:

import java.io.IOException;
import java.util.Vector;

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DataElement;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.UUID;

import net.rim.device.api.bluetooth.BluetoothSerialPort;
import net.rim.device.api.system.AccelerometerSensor;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.Backlight;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.system.AccelerometerSensor.Channel;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Status;
import net.rim.device.api.ui.container.MainScreen;

public final class DEF extends MainScreen       //DEF class
 implements DiscoveryListener
{
    //Constructor
    public DEF()        //DEF
    {

    }       //End of initscreen

    public void serviceSearchCompleted(int transID, int respCode)       //servicesearchcompleted
    {
        // TODO Auto-generated method stub
        switch (respCode)       //Select which response code
        {
        case SERVICE_SEARCH_COMPLETED:      //Service search completed
                if (AccelerometerSensor.isSupported())      //Accelerometer is support
                {
                    Channel accchan;

                    //Start querying the accelerometer sensor
                    //accchan = AccelerometerSensor.openRawDataChannel(super.getApplication());
                    //accchan = AccelerometerSensor.openRawDataChannel(UiApplication.getApplication());
                    //accchan = AccelerometerSensor.openRawDataChannel(UiApplication.getUiApplication());
                    //accchan = AccelerometerSensor.openRawDataChannel(Application.getApplication());
                    //accchan = AccelerometerSensor.openRawDataChannel(this.getApplication());
                    //accchan = AccelerometerSensor.openRawDataChannel(motor_car_2.getApplication());

                    int ori  = accchan.getOrientation();

                    //Stop querying the sensor
                    accchan.close();

                    switch (ori)        //Select which direction
                    {
                    case AccelerometerSensor.ORIENTATION_BOTTOM_UP:     //North
                    case AccelerometerSensor.ORIENTATION_TOP_UP:        //North
                    case AccelerometerSensor.ORIENTATION_RIGHT_UP:      //West
                        //Force to west direction
                        Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_WEST);
                        break;      //End of north or west

                    case AccelerometerSensor.ORIENTATION_LEFT_UP:
                    default:        //East, horizontal or unknown
                        //Force to east direction
                        Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_EAST);
                        break;      //End of east, horizontal or unknown
                    }       //End of select which direction
                }
                else        //Accelerometer is not support
                {
                }       //End of accelerometer is not support
            break;      //End of service search completed
        }       //End of select whioch response code
    }       //End of servicesearchcompleted
}       //End of DEF class

I think that this problem may be due to my poor concept in Java. Please provide some tips.

Note: The class DEF is a listener of bluetooth device discovery. I run in debug mode and make sure that the code executed at these lines open the accelerometer. But all return null. So I can't treat more steps.

My target is to detect the orientation of the screen and the limit to this complementary process direction.

Thank you for your help in advance.

Best regards

Albert Siu

Fix there issue.

The issue is due to bad I opened the channel as a channel of raw. If it throws an exception in the getorientation function.

Thanks for your help.

Tags: BlackBerry Developers

Similar Questions

  • The Web Acceleration Client error (513) - internal error of the Web acceleration Client has detected an internal error that caused the connection between the accelerometer of the Web

    The Web Acceleration Client error (513) - internal error
    The Web acceleration Client has detected an internal error that caused the connection between the customer to accelerate Web and server acceleration Web to be broken. A new attempt of the web page may correct the problem.

    I get this error at all times when working in the ancestry.com Web site. I have to reload the page on almost every search I do on this Web site. It is the site of the ONLY I get this error message, can run uninterrupted for several hours on other sites and never get this message. I talked to the people at Ancestry.com support and they did 2 recommendations: turn antivirus (did not help) or switch to another web browser. I tried both 11 IE and Chrome Version 31.0.1650.63 m and I have no problem with either of these 2 browsers this error.

    Is there a problem with the way Firefox and ancestry.com communicate?

    Hello byron.lewis, many site problems can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.
    Note: This will be you temporarily disconnect all sites, you're connected to.
    To clear the cache and cookies to do the following:

    1. Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
    2. Under "Time range to clear", select "all".
    3. Now, click the arrow next to details to toggle the active details list.
    4. In the list of details, see the Cache and Cookies and uncheck everything.
    5. Now click the clear now button.

    More information can be found in article to clear your cache, history, and other personal information in Firefox .

    This solve your problems? Please report to us!

    Thank you.

  • How to perform the FFT on medium thanks to the accelerometer is correct or not?

    Hello

    I do FFT on medium thanks to the accelerometer, but display is not correct? Can someone help me solve this problem. I use PKI accelerometer and connecting to NI WSN NŒUD 3202.

    What is the purpose of feeding one of the TFF to a chart with each iteration of the loop? You have found the spectral components different FFT of different sets of data. The graph of the whole picture emerging from the FFT.

    Lynn

  • cRIO and 9234 modules do not work or communicate via fpga with accelerometers, fpga, connected to the real-time application is also related to shared variables related to modbus slave

    Hello

    I have a compact rio, which has a 4 way frame this chassis is the three modules of ni9234, they are related using FPGAs for application in real time, then using shared variables in the low-speed loop associated with a slave modbus to communicate with the domain controllers, the nor 9234 accelerometers linked to them with option ac coupled iepe on c modules , my problem is the real-time application seems to work well even when power loss occurs it restarts without problem and the fpga written hard disk portable bin files very well, but without an accelerometer connected I get readings of low noise as soon as I connect an accelerometer to one of the outputs 10 it just goes to a fixed number (0.03125) as soon as you unplug it again He returned to readout noise, I ran a scan on the modules and get only a spike when I connect or disconnect the accelerometer, I tested voltage at the pins on the module and I get 22 volts CC which makes it more likely that the material is not the problem, but software is perhaps the cause to hang up, I join the project and files for your perusal. I also realized a new project which, in mode directly linked scan has the module entry in the shared variable and the scenerio even once again. Help would be appretiated.

    Thank you very much

    Jason

    Whren using waveform with the 9234 acquisition, we recommend the following FPGA and RT model.

    http://sine.NI.com/NIPs/CDs/view/p/lang/en/NID/209114

    It can be extended as a datalogger with:

    http://zone.NI.com/DevZone/CDA/EPD/p/ID/6388

    or using shared variables combined with the analytical engine

    http://zone.NI.com/DevZone/CDA/tut/p/ID/9851

    The FPGA in all this, as well as the framework of RT have used successfully by 1000s of users.  I recommend giving these a try.

  • Mulitasking on Casacde (Backbround thread for reading the accelerometer and in the foreground UI update)

    Hello

    I make application to read data from the accelerometer. I create the user interface using C++ and when the user clicks on the application startup button taking users accelerometer reading. I tried to update x, position y of the component and textarea or a text label. How can I do?

    I've attached my app.cpp file in which I want to update the text of button or label and move the image to different x, the coordinate y.

    I'm multitasking successfully implemented over the waterfall.

    Here is my code in which the two wire work in parallel.

    Step 1: Extend the class with the Thread class

    Step 2: The signal whenever you want to update your UI Thread class

    Step 3:

    QObject::connect (myThread, SIGNAL (signalGUI (float, float, float)),)
    SLOT (showUpdatedData (float, float, float)));

    myThread is an object of the class as we thread createad by exteding the Qthread.

    signalGUI is a signal that emerging us from the worker thread.

    showUpdatedData is a slot in which we write the code to update the GUI.

    In this way we can implement multitasking on the waterfall.

  • App store, Safari and iTunes does not connect to the Internet after installing macOS Sierra

    App store, Safari and iTunes does not connect to the Internet after installing macOS Sierra

    After upgrade 'OS X El Capitan' to "macOS Sierra" window only empty "App store" and page "Safari" made its appearance, no error message shows. store "iTunes" and "Dictionary" does not connect too.

    But Google chrome works well.

    So have you tried the next steps in your original post that Safari does not work after installing macOS Sierra:

    (1) x OS: "Unable to connect" or "unable to connect to the App Store. An internet connection is required"- Apple Support

    2) Advanced the steps to correct the problems with the iTunes Store - Apple Support connection

  • iPad connects to the network, is unable to connect to Internet

    Received my new iPad. Automatically, it connects to my home network but does not connect to the Internet. I rebooted the router and the iPad, but the same thing. Same problem with the old iPad. That is what it is?

    Hello. When you go into settings > WiFi and tap the current network, that see you the IP address and other network settings, or they are all empty? You use DHCP to configure?

  • My 5s iphone suddenly showed no service, then I made an attempt to update to ios and itunes connected, now iphone is not enable and display cannot connect to the server and in itunes it shows unable to check your device.please help me

    My 5s iphone suddenly showed no service, then I made an attempt to update to ios and itunes connected, now iphone is not enable and display cannot connect to the server and in itunes it shows unable to check your device.please help me

    Assuming that you have a valid SIM card in the phone, it is more often symptomatic of a phone that has been hacked or jailbroken to unlock.

    Where do you have the phone first?

  • Can not connect to the WiFi on MacMini 2014

    When I try to connect to any WiFi on my MacMini it says ' Unable to join, try to get closer the router. but the router is right next to my Macmini.

    In addition, my wifi connection is correct. It is easily connected to my iPad and iPhone.

    I tried transferring a file using release from my iPad to MacMini. It worked.

    When I tried to connect to the MacMini with ethernet cable, it worked too!

    The only problem is that I can't connect to the router using the wifi on my MacMini.

    What should I do?

    Try to create a new network location:

    Using network locations (Mac OS X 10.6 and later)-Apple Support

    Try to connect as a different user.

    Have you removed the Mini?

    AirDrop uses bluetooth

    http://iPad.about.com/od/iPad_Guide/SS/what-is-AirDrop-how-does-it-work.htm

  • Change of keyboard USB external Apple connected to the Macbook Pro

    Dear ladies and gentlemen,

    I need your help. I have a MacBook Pro running the last Sierra 17 "MacOS. I bought a 27 "Thunderbolt display and wanted to use a full external keyboard USB Apple (with the help of the digital keys). I have connected to the screen "USB port, closed down the internal screen MacBook... magic happened... keyboard poped office to the top of the screen external AND external full resolution was working properly..." Unfortunately only for 1-2 minutes, then the layout changed back irreversible in a layout resembling the layout if I would press "alt". Only way I could "resolve" to disconnect the keyboard USB plug and then plug again... but after 1-2 minutes did the same thing...

    I tried to plug the USB plug into the MacBook Pro directly, but the same thing happened...

    I am so unhappy that I can't use correctly the full length external Apple keyboard, large... Any hint/resolution?

    Thank you for your help in advance,

    Péter

    System Preferences > keyboard > Input Sources > [√] see Input menu in the menu bar

    ... then the menu icon before, choose «Show Keyboard Viewer»

    Now, look at the chart of the keyboard that appears on the screen. If the Alt/Option key is stuck, the key will be gray, as if it is held down. If you press it again, he himself is not?

  • Unable to connect on the Messages or FaceTime after upgrading to Sierra

    Good afternoon! After upgrading my MacBook Pro (13-inch, mid 2010) to macOS Sierra (10.12.), I am unable to connect to Messages or FaceTime. They worked fine before the upgrade.

    • Messages: After entering my Apple ID and password, I get the message "Could not sign in iMessage." "Could not sign. Please check your network connection and try again. "or"an error has occurred during authentication. "My network is connected to the network (where this message), and the password is correct. Also, I have generated a password app specific to Messages. Enter just grew the message "your Apple ID or the password is incorrect." Messages is works well with my Google Talk and AIM accounts.
    • FaceTime: After entering my Apple ID and password, the engine just turns and it never connects me. Similarly, I have generated a password app specific but use it just gets the message, "your Apple ID or the password is incorrect."

    No idea how I can regain access to these applications? Thank you!

    Reached out to the Twitter account of Apple Support. He proposed to restart. It worked.

  • "iPhone is disabled, connect to iTunes" AND "iTunes can not connect to the iPhone because it is locked with a password" error message on the phone and the computer! Help!

    So I recently had my password wrong too many times and my iPhone 4S locked out telling me "iPhone is disabled; Connect to iTunes'. And so I connected to iTunes and decided to restore my phone. I finished the process of restoration of the configuration of my phone, but ultimately, it was not even let me in the phone! Once AGAIN he said "iPhone is disabled; " Connect " to iTunes '. However, this time, this message appeared just when I turned on my phone with a black background. I didn't scan the screen for the error message is displayed (and there was no time to be shown). When I tried to connect to iTunes again as he asked, now it says "iTunes can not connect to the iPhone because it is locked with a password".

    So now, he said "iPhone is disabled; ' Connect to iTunes' on my iPhone 4S and ''iTunes can't connect to the iPhone because it is locked with a password ' on my computer. WHAT should I do?

    As described in step 2 of "Erase your device with iTunes" in this article, you will need to use the Recovery Mode.

    Recovery mode is described in this article as well.  You may try to go into recovery mode more than once to succeed.

    If you have forgotten the password for your iPhone, iPad or iPod touch, or your device is disabled - Apple supports

  • Why always show that "there is a connection to the Apple store error."? It has been a month I am facing such a problem. How can I fix? Hope you have a solution to this...

    Why always show that "there is a connection to the Apple store error."? It has been a month I am facing such a problem. How can I fix? Hope you have a solution to this...

    I don't know if this is the problem, but it is something that must be correct establish a secure connection:

    Open Date and time preferences system, Date & time tab. Make sure that it is set to automatically set the time.

    Alternatively, make sure that your date/time is correctly set to the second.

    Another thing to try is to restart your modem and router.

  • Devices to connect to the airport, but not to the Internet

    Hi all; Here's my situation:

    I just bought a new Airport Extreme to replace my old router (Linksys). In our House, we have two iPhones 6, as well as the iPad, Apple TV and MacBook Pro that were all bought again this year. All these things were able to connect to the internet using our old wireless router.

    As I have configured and installed at the airport, various devices have been able to connect without being able to connect to the internet (i.e. AirPort Utility, the airport connection is a green dot, while the actual internet connection is an orange): first it was the MacBook having this problem while the phones and the iPad have been completely connected. After I simply rebooted everything several times - i.e. the modem, router, and MacBook - I finally got the MacBook fully connected (without really changing all the settings, which are all entered correctly). Now, however, it is the two iPhones that will connect the airport but not actually in the internet.

    Any ideas? I must say, these strange little problems idiopathic who seem to always pop up with Apple products are starting to really bother me... I never got my MacBook to connect to the Apple TV via AirPlay.

    Any time you change the material or providers of Internet services, networking, it's always a good idea to perform a complete recycling of your network equipment power. Check out the following Tip of an airport users for more details on how to do it. Please post back your results.

  • Unable to connect to the internet using Ethernet

    I have a Mac mini as I try to connect via Ethernet cable to a modem Comcast Arris TG862. I was connected via Wifi without problem (with the exception of the slower speeds). I know that the Ethernet ports on the back of the modem seem to work, since I can listen to my TV, etc. In settings > network Ethernet shows as green and connected and gives me an IP address, but as soon as I turn off Wifi no web page doesn't load.
    What I am doing wrong? I thought that it would just connect. On the Ethernet port lights, which I think means data transfer. Otherwise, I need to tell Firefox or Chrome to turn to the Ethernet connection?
    Thank you!

    The default configuration is to have the WiFi over Ethernet in the Service order.

    The order must be set such that the (desired) primary service is at the top of the list and the backup service is below.

    If you look at the order of service when it is connected to the network, the higher is the provision of access Internet one (or at least, he thinks Yes).

    To set the order, click on the menu of the machine and choose the order of Service. Move Ethernet to the top of the list. This should make it primary unless he loses the connection.

    However, it must move up Ethernet and provide a connection when you have turned off the WiFi. When you disable WiFi on the Mac, the Ethernet connection move to the top of the list and show a green connection?

Maybe you are looking for