Re: [android-developers] override back button

2011-03-10 Thread Justin Anderson
Starting with Android 2.0 you also need to implement onBackPressed() in
order to achieve this...
http://developer.android.com/reference/android/app/Activity.html#onBackPressed%28%29

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Thu, Mar 10, 2011 at 2:36 PM, TreKing  wrote:

> On Thu, Mar 10, 2011 at 1:54 PM, Colin  wrote:
>
>>  return super.onKeyDown(keyCode, event);
>
>
> The "super" method likely executes the default action for the given key
> press.
> The default action on the back key is to call finish() on the activity.
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> 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
>

-- 
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] override back button

2011-03-10 Thread TreKing
On Thu, Mar 10, 2011 at 3:36 PM, TreKing  wrote:

> On Thu, Mar 10, 2011 at 1:54 PM, Colin  wrote:
>
>>  return super.onKeyDown(keyCode, event);
>
>
> The "super" method likely executes the default action for the given key
> press.
> The default action on the back key is to call finish() on the activity.
>

And on second review of your code, I see you only do that if the key is not
the back key. Don't mind me.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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] override back button

2011-03-10 Thread TreKing
On Thu, Mar 10, 2011 at 1:54 PM, Colin  wrote:

>  return super.onKeyDown(keyCode, event);


The "super" method likely executes the default action for the given key
press.
The default action on the back key is to call finish() on the activity.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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] override back button

2011-03-10 Thread Dia
Hello,

Does your Back Button exit the application in both cases? When
animation.state!=1 it should not do anything.  In the other case it should
exit.

>From documentation:

   - "If you handled the event, return true. If you want to allow the event
   to be handled by the next receiver, return false."

Hope this helps.

On Thu, Mar 10, 2011 at 9:54 PM, Colin  wrote:

> Can someone help me understand how to stop the back button from
> exiting out of my program?  I want it to just return to my main menu
> or exit if pressed on the main menu but when I override the method it
> still exits.  Here is what I currently have:
>
>@Override
>public boolean onKeyDown(int keyCode, KeyEvent event)  {
>if (keyCode == KeyEvent.KEYCODE_BACK &&
> event.getRepeatCount()
> == 0) {
>if (animation.state != 1){
>animation.state = 1;
>return true;
>}
>else return false;
>}
>
>return super.onKeyDown(keyCode, event);
>}
>
> I have messed with it a little but my program is always still closes.
>
> --
> 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

-- 
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] override back button

2011-03-10 Thread Colin
Can someone help me understand how to stop the back button from
exiting out of my program?  I want it to just return to my main menu
or exit if pressed on the main menu but when I override the method it
still exits.  Here is what I currently have:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
if (keyCode == KeyEvent.KEYCODE_BACK && 
event.getRepeatCount()
== 0) {
if (animation.state != 1){
animation.state = 1;
return true;
}
else return false;
}

return super.onKeyDown(keyCode, event);
}

I have messed with it a little but my program is always still closes.

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