当我想要显示小部件并开始监听时,我会立即收到以下异常:
// 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)
...
我的代码中的源代码如下所示:
mAppWidgetManager = AppWidgetManager.getInstance(context);
mAppWidgetHost = new AppWidgetHost(context, R.string.app_name);
mAppWidgetHost.startListening(); // <= this line leads to the crash
观察结果
- 我的应用在很多手机上都正常工作(实际上只有一个例外)
- 上述崩溃仅在一个用户设备上发生(SM-N910C (三星Note 4), Android 6.0.1)
- 用户说,在他的启动器中这些小部件可以很好地工作
有人知道是什么原因导致了这个问题吗?这是我可以在我的应用程序中解决的问题吗?用户表示小部件在他的启动器中工作正常...