try this
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { super.onKeyDown(keyCode, event) do something return true; } return false; } On Jan 11, 5:14 pm, vani reddy <vani.reddy.bl...@gmail.com> wrote: > Thanks. > I tried this , the problem is onKeyDown is never fired > > On Wed, Jan 11, 2012 at 5:41 PM, Ratheesh Valamchuzhy > <android...@gmail.com>wrote: > > > > > > > > > > > try this > > > public boolean onKeyDown(int keyCode, KeyEvent event) { > > if (keyCode == KeyEvent.KEYCODE_BACK) { > > moveTaskToBack(true); > > return true; > > } > > return super.onKeyDown(keyCode, event); > > } > > public void backButtonPressed(View v) { > > //do this > > > } > > > -- > > 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 > > -- > Regards, > Vani Reddy -- 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