Widgets lead to DeadObjectException - transaction failed on small send

I get the following exception as soon as I want to show the widget and start listening:

// the relevant stack trace, the rest is comming from my code // before the code line I posted below java.lang.RuntimeException: system server dead? at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:189) at com.my.app.utils.WidgetUtil.a(SourceFile:231) ... android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:503) at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:481) at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:185) at com.my.app.utils.WidgetUtil.a(SourceFile:231) ... 

The source in my code is the following code:

  mAppWidgetManager = AppWidgetManager.getInstance(context); mAppWidgetHost = new AppWidgetHost(context, R.string.app_name); mAppWidgetHost.startListening(); // <= this line leads to the crash 

Observations

  • my application works fine on many phones (all but one actually)
  • Above accident occurs only on one user device (SM-N910C (Samsung Note 4), Android 6.0.1)
  • user says these widgets work great in their launcher

Does anyone have any ideas what might cause this? Is this something I can solve in my application? The user says that the widgets work fine in their launcher ...

+5
source share
2 answers

So, a simple google search led me to this DeadObjectException definition: -

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

It can be seen from this that you are getting this error because the process in which the mAppWidgetHost hosted mAppWidgetHost been deleted.

Now the question is why you get this error. Overriding and logging onDestroy() for monitoring can be useful, and it is definitely worth onDestroy() snapshot. But, since it works on all devices except one, it is more likely that there is nothing wrong with the onDestroy() method. Instead, the OS disables the process before you can access the object.

So now why is the OS doing this? This question made me drag out for a long time. I still do not have a clear answer or solution, despite the fact that Google searches with all the related problems. But, having spent a lot of time searching, I noticed a feature - most of the problems with this exception, for example, this one , and your hearing with Samsung devices.

I guess Samsung's underlying architecture leads to this problem. And, although I have no reason why this is happening or a plausible solution even after repeated searches, it can still be the beginning of working with targeting Samsung devices.

UPDATE

I searched a little more and came across this answer. Take a look at the last comment of the author of the question on the question: -

Finally, it only works fine on the line of code in the manifest file, here it is android:hardwareAccelerated="false" If someone gets the following errors, try adding the aforementioned signal of line 11 (SIGSEGV), code 1 (SEGV_MAPERR)

I do not know the logic of this or if it will work or not. Just share it with the hope that he can help you - even in the smallest form.

+1
source
 DeadObjectException : 

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

Possible solutions:

1) Override the onDestroy() service method and see what event stream leads to it. If you catch DeadObjectException without passing this method, your service must be killed by the OS.

2) by deleting Typeface , this may be due to ttf, which I used from the resource folder. Try to comment on the font and test it, I hope that it will work for sure.

3) enter all code inside onCreate . From there you will see what a criminal is, for example, NullPointerException , but your code will work exactly already.

0
source

Source: https://habr.com/ru/post/1271936/


All Articles