tags:

views:

12

answers:

1

hi in android i want to print the key codes for each and every key which i pressed. i am not getting any method from which i can print key codes. plz help me because without getting keycode i m unable to complete my project.

+1  A: 

You could override these methods in your activity:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event);

@Override
public boolean onKeyUp(int keyCode, KeyEvent event);
Mathias Lin
Thanks.. it is working..but its not giving me home key and KEYCODE_ENDCALL key code. why? actually i want that if user press home key than an alert should be there not the home page? is this possible??
nimi
you cannot catch the home key. you can only define an activity as a default home intent, but not catch the keypress event in onKeyUp/Down. That's a restriction so that developers cannot keep users caught in their app.
Mathias Lin