Thanks, Mark. That was helpful.

> 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.

Is there a way for an (sub-)activity to pass values to the previous
activity on the stack (when Back key is pressed) without resorting to
persistence storage or static varables in the app?


On Sep 11, 5:20 pm, Mark Murphy <[email protected]> wrote:
> 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 [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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to