jason wrote:
> Is there a
> way to trap Back key within an application and prevent/control this
> behavior?

Implement onKeyDown() in your activity and watch for KeyEvent.KEYCODE_BACK.

Please bear in mind that your users will get irritated if you make it
difficult for them to navigate your application, so make sure if you
override the BACK button, it is for a good reason, not just because you
do not like the BACK button.

For example, with the built-in Browser application, the BACK button is
used for going back in the browsing history. While this is fairly
natural, I still get frustrated at times because I try to use the BACK
button to exit the Browser and merely go back a page. When the vast
majority of apps use the BACK button to exit the current activity, it is
sometimes difficult for users to adjust to applications that choose to
handle this differently.

Or, possibly, I'm just a moron.

> For sub-activity screens, does the Back key have the same behavior
> (killing the app/activity) or does it go back to the parent activity
> in the stack?

If you are referring to activities started by one of your activities via
startActivity(), then, yes, the BACK button behaves the same. The BACK
button's job is to destroy the current activity and return control to
the previous activity on the stack.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to