Note that this will work only for phones running 2.0 and up. For phones running 1.6 and lower, you need to handle the key-down and key-up of the back-key.
On Dec 22, 2:37 pm, Prateek Jain <[email protected]> wrote: > Hi, > > If you just want to disable the back button and do nothing, you can > try this - > > @Override > public void onBackPressed() > { > // Your code here, If you wish to write any, else no > need. :-) > } > > Thats it !!! > > Cheers, > Prateek > > On Dec 22, 5:06 pm, Abhilash baddam > > > > <[email protected]> wrote: > > Thanks kostya it's working fine... > > > On Wed, Dec 22, 2010 at 5:27 PM, Kostya Vasilyev <[email protected]> wrote: > > > Starting with API level 5, you can override onBackPressed(). > > > > For previous API levels, use something like: > > > > @Override > > > public boolean onKeyDown(int keyCode, KeyEvent event) { > > > if (keyCode == KeyEvent.KEYCODE_BACK) { > > > // your code here > > > return true; > > > } > > > return super.onKeyDown(keyCode, event); > > > } > > > > Whether this is a good idea is another question. > > > > Also note that the user can still use the Home key to leave the activty, > > > and you can't override that. > > > > -- Kostya > > > > 22.12.2010 14:49, vikram jain пишет: > > > > use back.setVisible(false) > > > > On Wed, Dec 22, 2010 at 5:18 PM, Abhilash baddam < > > > [email protected]> wrote: > > > >> Hi friends, > > > >> Suppose i have an activity which displays a text like > > >> hello..when the user click on back button i don't want > > >> to work that key instead i want to display a toast which shows > > >> back button not works here . How can we disable that > > >> key programmatically. > > > >> Any suggestions please... > > > >> Regards, > > >> Abhilash.B > > >> -- > > >> You received this message because you are subscribed to the Google > > >> Groups "Android Developers" group. > > >> To post to this group, send email to [email protected] > > >> To unsubscribe from this group, send email to > > >> [email protected]<android-developers%2Bunsubs > > >> [email protected]> > > >> For more options, visit this group at > > >>http://groups.google.com/group/android-developers?hl=en > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > > Kostya Vasilyev -- WiFi Manager + pretty widget > > > --http://kmansoft.wordpress.com > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected]<android-developers%2Bunsubs > > > [email protected]> > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

