Events not catched on real device using Activity.dispatch<EventType>

by TjerkW » Sun, 12 Apr 2009 20:20:45 GMT

Sponsored Links
 Hello all!

I am creating a game in which the user can control a ship by
- Using DPAD
- Using touchscreen
- Using trackball
- And even using orientation events (roll pitch etc)

It all works on the emulator but when i open the game on a real device
the events (touch, trackball) do not work anymore.

I am catching evetns by overriding the dispatch<EventType>() methods.
This is the code in my Activity class that catches the events:

  public boolean dispatchKeyEvent(KeyEvent e) {
                return controller.onKeyEvent(e.getKeyCode(), e);

        public boolean dispatchTrackballEvent(MotionEvent e) {
                if(settings[2] || settings[3]) {
                        return controller.onTrackballEvent(e);
                } else {
                        return super.dispatchTrackballEvent(e);

        public boolean dispatchTouchEvent(MotionEvent e) {
                if(settings[1]) {
                        return controller.onTouchEvent(e);
                } else {
                        return super.dispatchTouchEvent(e);

I think the dispatchKeyEvent(..) method works fine, but the other ones
do not work on a real device.
They work without problems on the emulator.

What am i doing wrong?
I really do not understand it.

Thanks in advance.

Tjerk Wolterink


Other Threads

1. Could not find method, referenced from method org.ksoap2.transport.ServiceConnectionMidp.

Hi Everyone,

I've been getting this error "Could not find method, referenced from method

Can anyone help?


2. Transparency/Translucency working on emulator but not device

I have tried to replicate the Transparency/Translucency effects
created in the API Demo(which works flawlessly) and the code i wrote
works on the emulator but not on my actual device(Google ION)

I copied the styles and colors.xml files from the API demos code and
set the theme of my activity I want to be transparent to "@style/
Theme.Transparent" in my activity i set my content view to a layout
which contains only a TextView containing :
<TextView xmlns:android=""
    android:text="should have transparent background"
 i have also tried setting the theme using: setTheme

but nothing I try seems to work on the device, Any thoughts? is there
something I am missing?



3. new app please

4. how to call Camera application from my own application

5. Is a five-way navigation key a mandatory requirement?

6. getting an image from a video on android

7. How to do instrument test on context menu?