I understand your problem is that the dialog box pops up when you hit *any* key. This is the expected behavior; onKeyDown() is called when any key is hit. You can filter out the desired key code by calling getKeyCode() for the KeyEvent that is passed to the overridden onKeyDown(). Then direct your action accordingly. In your case, when you receive KEYCODE_BACK. Here's the relevant documentation for more information: http://code.google.com/android/reference/android/view/KeyEvent.html Hope this helps.
On Jan 27, 10:28 pm, manoj <manojkumar.m...@gmail.com> wrote: > Hi, > > I want to show some alert message when some one clicks on back button. > > Actually I am using it in a class which extends TabActivity. > > I implemented the kode as > > public boolean onKeyDown(int keyCode, KeyEvent event) > { > > System.out.println("(onKeyDown) is called in > RadioChannelsInfo.java"); > System.out.println("(onKeyDown) is called in > RadioChannelsInfo.java"); > System.out.println("(onKeyDown) is called in > RadioChannelsInfo.java"); > System.out.println("(onKeyDown) is called in > RadioChannelsInfo.java"); > System.out.println("(onKeyDown) is called in > RadioChannelsInfo.java"); > System.out.println("keyCode ->"+keyCode); > System.out.println("event"+event); > > showDialog(DIALOG_YES_NO_MESSAGE); > > return true; > } > > it shows the dialog message when I click on right and left keys of the > mobile (emulator), but when I click on up, down and back button. > > I want the dialog message should up when we click on keypad's back > button. > > How should I do? > > Can any one please help me? > > Thanks, > Manoj. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---