Atif Gulzar wrote:
> I just read from internet to maintain the state of my application by
> overriding the onKeyDown function as given below. And set the launch
> mode of my activity as singleInstance. And it is working perfectly. Just
> want to know if it is correct approach. And how it is different from
> onSaveInstanceState. Thanks
> 
>    @Override
>     public boolean onKeyDown(int keyCode, KeyEvent event)
>     {
>        if (keyCode == KeyEvent.KEYCODE_BACK)
>           return this.moveTaskToBack(true);
>        return super.onKeyDown(keyCode, event);
>     };

This has nothing whatsoever to do with saving your state.

The Bundle you populate in onSaveInstanceState() will be saved if your
activity is destroyed and recreated, either because of a configuration
change (e.g., user rotates the screen) or because of memory reclamation.
What you are doing here does not help with either of those cases.

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

_Android Programming Tutorials_ Version 1.0 In Print!

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