Home » Android » android – How to handle DeadObjectException?

android – How to handle DeadObjectException?

Posted by: admin May 14, 2020 Leave a comment


I’m getting exception reports of DeadObjectException from some devices when requesting prices for in app purchases. The exception occurs when I call getSkuDetails on my billing service connection.

I don’t find the documentation on this particularly clear.

The object you are calling has died, because its hosting process no longer exists.

  1. Am I understanding this correctly if I assume that the billing service has been killed by Android for some reason?
  2. Why?
  3. Is there a way to stop this from happening?
  4. Should I stop this from happening?
  5. How should I deal with the exception?
  6. Is there a way I can reproduce this scenario for testing?

I have two methods

void bindToBillingService() {
    AndroidLauncher.getActivity().bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
            mServiceConn, Context.BIND_AUTO_CREATE);

public void unbindBillingService() {
    if (getBillingServiceConnection() != null) {

Should I be doing something like this?

    try {
        // Do something billing related
    } catch (DeadObjectException e) {
        // Wait for a connection and then try again
How to&Answers: