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. how to send String/Int from subActivity to mainActivity without close the SubActivity

hi all,

does anyone know how to get result from subactivity to MainActivity
without close the subactivity?

i know the usual way is using method called "startActivityForResult
(Intent intent, int requestCode)"
and inside the subActivity set the result 1st before finish(); method


then the function called "protected void onActivityResult(int
requestCode, int resultCode, Intent data)" which is inside main
activity will get the result.


by using that way, it will close my sub activity and the system will
go back to main activity.

i already try to make my own listener and try to apply it, but it's
useless, because there will be nullException in subActivity even thou
inside the MainActivity i already set the listener. Hence i summarized
that by using listener the Activity can't talk each other.

anyone have any idea how can i do it?

thank you.


2. (wta)id imobsters

siang akang2 nu ganteng sesuai dengan judul
saya mau minta id imobsters donk..
ane mulai ketagihan nih...

ato ga ane minta di add deh id ane : 5DFJW6
makasih sebelumnya..

"Indonesian Android Community [id-android]" 

3. Serious Issue

4. Twitter app's popup aligned with ListView item - how did they do it?

5. Moving 2d shape on camera preview

6. Very weird problem !!

7. How to solve these issues?