I would strongly advise against fighting the normal stack-based work-
flow of android activities.
If the user pressed the back-key, he/she probably wants to 'go back'.
Don't fight your customer on this. Don't try to break or modify the
work-flow model of Android.

But, if you must, you could warn the user by implementing onKeyUp/
onKeyDown or onBackPressed methods of your activity and prevent the
'native' handling of the back-key press there. Popup a dialog. If the
user says 'OK', then call 'finish()', otherwise do nothing. Still, do
this if only you absolutely must! I still advise against it.


On Apr 27, 3:43 am, Xiongzh <[email protected]> wrote:
> Yes, I have keep in back stack what should in the back stack.
> But sometimes customers just want to navigate to the activity in the
> bottom of the stack, i.e, the first view the see, the main view I
> assume. They are not intent to leave my application.
>
> That's why they ask for a confirmation when they leave by back button.
>
> On Apr 27, 3:31 pm, patbenatar <[email protected]> wrote:
>
>
>
>
>
> > Wait I'm a bit confused... If the user wants to hit the back button to
> > go back to the previous Activity, I'm assuming you're talking about a
> > previous Activity within your app? This functionality is native to
> > Android and should be maintained throughout your app. If you start an
> > activity for result and then finish it, it will be removed from your
> > back stack. If your users complain that the back button does not act
> > natively [going back to the previous Activity], maybe rethink how you
> > pass of from Activity to Activity throughout your app. If this page
> > the user wants to return to is important enough for your users to
> > complain about their inability to return to it, you should keep it in
> > the back stack so they can return to it.
>
> > Sorry if this is a misunderstanding of your message.
>
> > -Nick
>
> > On Apr 27, 12:22 am, Xiongzh <[email protected]> wrote:
>
> > > Some of my customers are accustomed to use the back button to go back
> > > to the previous activity. Some complained that they often navigate out
> > > of the application by pressing back button. I think it would be nice
> > > to customers if they can be warned.
>
> > > Thanks for your suggestion.
>
> > > How do think the approach I used?
>
> > > On Apr 27, 2:43 pm, Nicholas Albion <[email protected]> wrote:
>
> > > > My first thought was to suggest that you rethink if you really need to
> > > > do this - maybe your app isn't going to be as important to your users
> > > > as you may think.
>
> > > > But then, I been frustrated in the past by games which exit in the
> > > > middle of the game if you press too far right...
>
> > > > Maybe you should provide an option (which you'd only ever ask once):
> > > > "Always confirm before exiting"
>
> > > > > I can find some posts on how to warn user when the back button is
> > > > > pressed to 'quit' the application.
>
> > > > > The common answer is to catch the key down event by onKeyDown, or use
> > > > > startActivityForResult().
>
> > > > > My approach is to restart the activity in onStop().
> > > > > Is it a better choice?
>
> > > > > Please help to check if there's anything inappropriate.
>
> > > > --
> > > > 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 
> > > > athttp://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 
> > > athttp://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 
> > athttp://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 
> athttp://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

Reply via email to