• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Handleing key events

krishnan

Newbie
Jun 10, 2010
10
1
Hi
I am new to android. and trying to check what key is pressed from the emulator keyboard.
Here is my code. Which is not giving me expected results. I have commented some of the code as that was not working.
Please let me know how i can fix this issue.

Code:
public class DynamicMenu extends Activity{
//implements  OnKeyListener {
    Menu theMenu;
    int i = 0;
   /** Called  when the activity is first created. */
    @Override
    public  void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
    }
    
    
    @Override
     public boolean onCreateOptionsMenu(Menu menu)
    {
        theMenu = menu;
       new  MenuInflater(getApplication()).inflate(R.menu.sample, menu);
        return (super.onCreateOptionsMenu(menu));
    }
//   @Override
//    public boolean onKey(View v, int keyCode, KeyEvent event) {
//       // TODO Auto-generated method stub
//      System.out.println("###  onKey");
//      return false;
//   }

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones