[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-28 Thread westmeadboy
My strategy is to only show a Toast (and maybe Vibration) (warning the
user that the next Back will exit the app) if the user has already
very recently (<2 secs ago) hit Back to return to the main activity
from a secondary activity.

This doesn't help the situation of accidentally hitting the back key
when you are trying to hit something else.

But in my app, its more common that users do something like Back-Back-
Back in an attempt to go to the main activity but actually overshoot
and exit the app. This solves that problem.

On Apr 28, 9:11 am, "Michael A."  wrote:
> Hi Xiongzh,
>
> Do something like the following where appropriate:
>
> @Override
> public boolean onKeyDown(int keyCode, KeyEvent event) {
>   if (keyCode == KeyEvent.KEYCODE_BACK) {
>     AlertDialog.Builder builder = new AlertDialog.Builder(this);
>       builder.setMessage("Quit Y/N?")
>                .setCancelable(false)
>                .setPositiveButton("Yes", new
> DialogInterface.OnClickListener() {
>                    public void onClick(DialogInterface dialog, int id)
> {
>                        MyActivity.this.finish();
>                    }
>                 })
>                .setNegativeButton("No", new
> DialogInterface.OnClickListener() {
>                    public void onClick(DialogInterface dialog, int id)
> {
>                        dialog.cancel();
>                    }
>             });
>         builder.show();
>         return true;
>     }
>     return super.onKeyDown(keyCode, event);
>
> }
>
> There are probably a few bugs in the above, but hopefully you get the
> basic idea.
>
> Regards,
>
> Michael A.
>
> --
> 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 
> 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 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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-28 Thread Michael A.
Hi Xiongzh,

Do something like the following where appropriate:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_BACK) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
  builder.setMessage("Quit Y/N?")
   .setCancelable(false)
   .setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int id)
{
   MyActivity.this.finish();
   }
})
   .setNegativeButton("No", new
DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int id)
{
   dialog.cancel();
   }
});
builder.show();
return true;
}
return super.onKeyDown(keyCode, event);
}

There are probably a few bugs in the above, but hopefully you get the
basic idea.

Regards,

Michael A.

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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Xiongzh
Yes, you're right!

too many side effects if implemented in onStop()

thanks

On Apr 28, 7:23 am, Dianne Hackborn  wrote:
> You should catch the back key, and do what behavior you want when it is
> pressed.
>
> Do not do this kind of stuff in onStop().  It is only going to cause you
> pain.  For example, the the user receives a phone call when in your app, the
> in call activity will be displayed, you will be stopped.  When they press
> home, you will be stopped.  When they use the status bar to switch to
> another app via its notification, you will be stopped.
>
>
>
> On Tue, Apr 27, 2010 at 12:45 AM, Xiongzh  wrote:
> > But it's totally transparent to the customer, isn't it?
> > The activity should be in the very top of the Android stacks. So it
> > would be bring up again quickly.
>
> > On Apr 27, 3:28 pm, patbenatar  wrote:
>
> > > Restarting the Activity in onStop sounds incredibly intrusive for your
> > > user experience.
>
> > > -Nick
>
> > --
> > 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
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>
> --
> 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 
> 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 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


Re: [android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Dianne Hackborn
You should catch the back key, and do what behavior you want when it is
pressed.

Do not do this kind of stuff in onStop().  It is only going to cause you
pain.  For example, the the user receives a phone call when in your app, the
in call activity will be displayed, you will be stopped.  When they press
home, you will be stopped.  When they use the status bar to switch to
another app via its notification, you will be stopped.

On Tue, Apr 27, 2010 at 12:45 AM, Xiongzh  wrote:

> But it's totally transparent to the customer, isn't it?
> The activity should be in the very top of the Android stacks. So it
> would be bring up again quickly.
>
> On Apr 27, 3:28 pm, patbenatar  wrote:
> >
> > Restarting the Activity in onStop sounds incredibly intrusive for your
> > user experience.
> >
> > -Nick
> >
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Mike
I've also had users complain that they accidentally pressed the back
button (usually on the Droid) while they were playing a game.  Now
that I have a Droid, I can see that this would be fairly easy to do
since the buttons are on the same pane of glass as the display.I
think the issue is with the phone and not because they are new to
Android.

- Mike



On Apr 27, 2:36 pm, patbenatar  wrote:
> Streets Of Boston is completely right.
>
> You say you have had users complain about hitting back and returning
> to Home.. These users must be new to Android and have not come to
> understand how their new mobile system functions. Think about how many
> users actually desire the native behavior from your application--I am
> willing to be this number will FAR outweigh the users who have filed
> complaints asking for non-native behavior. Stay native, and eventually
> your users will learn how their Android phones work and appreciate the
> fact that your app acts natively.
>
> -Nick
>
> On Apr 27, 7:11 am, Streets Of Boston  wrote:
>
>
>
> > 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  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  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  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  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 
> > > > > > android-developers@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > android-developers+unsubscr...@googlegroups.com
> > > > > > For more options, visit this group 
> > > > > > athttp://groups.google.com/group/android-developers?hl=en
>
> > > > > --
> > > > > You received this message because you are subscri

[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread patbenatar
Streets Of Boston is completely right.

You say you have had users complain about hitting back and returning
to Home.. These users must be new to Android and have not come to
understand how their new mobile system functions. Think about how many
users actually desire the native behavior from your application--I am
willing to be this number will FAR outweigh the users who have filed
complaints asking for non-native behavior. Stay native, and eventually
your users will learn how their Android phones work and appreciate the
fact that your app acts natively.

-Nick



On Apr 27, 7:11 am, Streets Of Boston  wrote:
> 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  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  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  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  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 
> > > > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com
> > > > > 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 android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com
> > > > 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 android-developers@googlegroups.com
> > > T

[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Streets Of Boston
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  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  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  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  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 android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com
> > > > 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 android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers

[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Zigurd
Maybe an audible cue that they are about to navigate back out? But, as
others have said, that navigation should have no bad consequences, so
the user need not be aware of it.

While a "home" navigation in the option menu is not desirable, that
would be one way to enable your users to return to the "top" of your
application. Give this "anchor" activity a meaningful name and give
the user a menu item so they can get to it from anywhere, if your
users really need that.

This article 
http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html
covers how navigation should work.

On Apr 27, 3:43 am, Xiongzh  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  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  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  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 android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com
> > > > 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 android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from thi

[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Xiongzh
But it's totally transparent to the customer, isn't it?
The activity should be in the very top of the Android stacks. So it
would be bring up again quickly.

On Apr 27, 3:28 pm, patbenatar  wrote:
>
> Restarting the Activity in onStop sounds incredibly intrusive for your
> user experience.
>
> -Nick
>

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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Xiongzh
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  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  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  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 android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread patbenatar
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  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  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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread patbenatar
You can override onBackPressed in your Activity. This is called when
the user presses the back button, before your Activity is finished by
the system. You could pop a dialog asking the user to confirm this
action, if they hit yes you call through to the super and the Activity
gets finished, if they hit no you do nothing and the Activity resumes
[I've never tried this, but AFAIK this should work]. Only problem is
this method is only available in Android 2.0+ [introduced in API Level
5].

Restarting the Activity in onStop sounds incredibly intrusive for your
user experience.

-Nick



On Apr 27, 12:22 am, Xiongzh  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  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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-27 Thread Xiongzh
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  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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 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


[android-developers] Re: How to warn user when back button is pressed to navigate out of my application?

2010-04-26 Thread Nicholas Albion
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 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