Saturday, April 30, 2011

[android-developers] When exactly do you need to handle DeadObjectException with services?

Hi there,

In the Additional Notes section here:
http://www.devdiv.com/android/docs/guide/topics/fundamentals/bound-services.html#Binding
it says: "You should always trap DeadObjectException exceptions, which
are thrown when the connection has broken. This is the only exception
thrown by remote methods."

1) Does that mean that for all calls of the client to the service's
methods you need to try/catch the DeadObjectException? Even
getService() in onServiceConnected() can throw it?

2) If my service only uses a local binder (LocalBinder in the example
from the above link), so it is private to my own application and runs
in the same process as the client, can I then still get
DeadObjectException? I wonder because I see with this type of binding
that the service does *not* appear in the services overview of a
device or emulator, which makes sense to me because it is "tightly"
connected to the activity that bound to it. That to me means you (nor
the Android runtime) can end the service on its own, so never a chance
on DeadObjectException... True?

Thanks!
Marco


--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate