Capturing Key/Touch Events

Put your problem here if it does not fit any of the other categories.

Capturing Key/Touch Events

Postby wonderoid » Sat Feb 16, 2008 10:57 pm

Hi everyone, this is my first post in these forums. (My English sucks beware :D)

My problem is; I want to capture key events at the lowest level (by a daemon, there won't be any views). All input will be directed to this service first. (So it will be able to deny input event dispatch to any activities running on the system.) I have been trying to find a way for some time now, but is this even possible? If it is; I want to extend the question to this-> Is it possible to intercept input events even for the main screen (the one that pops up when the emulator starts. Imagine that you click on the menu, and the service intercepts this so nothing happens) Can anyone help me on this one, any ideas appreciated.
wonderoid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Feb 16, 2008 10:33 pm

Top

Postby CHAKYANAS » Wed Mar 19, 2008 12:07 pm

import android.view.KeyEvent;

public class key extends Activity
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
//setContentView(R.layout.main);
}

//must be outside main


public boolean onKeyDown(int keyCode, KeyEvent event) {

if(keyCode == KeyEvent.KEYCODE_0){
showAlert("Key Pressed",0, "Key Pressed 0", "OK", false);

}

if(keyCode == KeyEvent.KEYCODE_1){
showAlert("Key Pressed",0, "Key Pressed 1", "OK", false);

}

return false;
}
}
User avatar
CHAKYANAS
Developer
Developer
 
Posts: 44
Joined: Mon Mar 03, 2008 5:08 am
Location: INDIA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests