onRetainNonConfigurationInstance() and ServiceConnection

Showing 1-3 of 3 messages
onRetainNonConfigurationInstance() and ServiceConnection Mark Murphy 9/23/10 6:18 PM
In an earlier thread on this group, it was pointed out that it is safe
to pass a properly-constructed AsyncTask object from an old activity
to a new one via onRetainNonConfigurationInstance(), so we can keep
the background work running when the device changes orientation, dock
status, etc.

What about ServiceConnection?

In other words, if an activity is bound to a service, is there a way
we can keep the binding alive during the configuration change, by
passing a properly-constructed ServiceConnection from the old activity
to the new? Or do we have to unbind in the old activity and bind again
in the new one?

Since ServiceConnection is just an interface, it should be fairly
trivial to have that object be clean for passing via
onRetainNonConfigurationInstance(). I'm just not sure if there's
something else held inside Android's innards that might get confused
if we do this.

Thoughts?

Thanks!

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

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!

Re: [android-developers] onRetainNonConfigurationInstance() and ServiceConnection Dianne Hackborn 9/23/10 6:42 PM
If you bind with the application context, it will be fine.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Dianne Hackborn
Android framework engineer
hac...@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.

Re: [android-developers] onRetainNonConfigurationInstance() and ServiceConnection Mark Murphy 9/23/10 6:52 PM
On Thu, Sep 23, 2010 at 9:42 PM, Dianne Hackborn <hac...@android.com> wrote:
> If you bind with the application context, it will be fine.

Awesome -- thanks!

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

_The Busy Coder's Guide to Android Development_ Version 3.1 Available!