Deadobjectexception on Android App

Activity Closed Throwing DeadObjectException with un-notified error code part

The process is being dead, because of the ambiguous context used in the both onClickListener to start activity, while passing the context to the list adapter, in have used getApplicationContext() to pass context to the adapter.

This the problem it could not host the process and killing the activity resulting in crash or DeadObjectException.

Problem in lines:

context.startActivity(intent);
context.startActivity(i);

and context given as getApplicationContext()

Solution:

Change getApplicationContext() to SomeActivity.this

And might be API28 has got its own new rules so, that's why it caused problem in devices with API28 or above.

Hope this helps others.

GetPackageInfo results in DeadObjectException

A better way to fetch your own versionName (which I assume you are trying to do, judging your code) is to call BuildConfig.VERSION_NAME. This requires that the App is built with gradle and the version is defined in your app.gradle file.

For the PackageManager Problem itself I have a theory, though only anecdotal (copying from my comment on the question):

I ran into the same problem a while back. It seems when the IPC Communication from the PackageManager tries to send too much data it somehow dies. It will stay dead until your app restarts. The only "solution" I found is to limit the data provided from getPackageInfo with it's flags.

DeadObjectException when pressure test

Through the analysis of the memory, it was found that the Handler object was repeatedly created when the AIDL command was initiated, and the Handler object was not cleaned up in time, resulting in a memory leak.



Related Topics



Leave a reply



Submit