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
then
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) {
                super.dispatchKeyEvent(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. Market Not Updating Version Info

I just uploaded a new version of my application to the Android Market
and then I choose to upload an update it doesn't update the version
number of the app.  It is only doing this as of Cupcake.  Anyone else
seeing this?
--~--~---------~--~----~------------~-------~--~----~

2. happiness with .png files?

I am playing with grid layout tonight, following the example code
posted by google.
All is well with the code, but android does not like some of my png files.

They are all about the same size...but when I put some into the
'grid', I get the application
has stopped unexpectedly error.

As I said, they are all .png and all about the same size.   What might
cause this?
-Mike

--~--~---------~--~----~------------~-------~--~----~

3. Sending mp3 file failed as email attachment

4. anyway to have sub-directories in the res/drawable folder?

5. overlay hardware interface and surfaceflinger interaction

6. Can OpenCore record a video and send it by RTP

7. Join the Android Developer Group on Linkedin!