如何修复 android.os.DeadObjectException android X

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1573557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:17:58  来源:igfitidea点击:

How to fix android.os.DeadObjectException android X

android

提问by n179911

When android unbind a service I created (service.MyService), I see the following DeadObjectException.

当 android 取消绑定我创建的服务 (service.MyService) 时,我看到以下 DeadObjectException。

Can you please tell me how what does this mean and can I fix this exception?

你能告诉我这是什么意思吗,我能解决这个异常吗?

W/ActivityManager(  583): Exception when unbinding service
com.mycompany/.service.MyService
W/ActivityManager(  583): android.os.DeadObjectException
W/ActivityManager(  583):       at
android.os.BinderProxy.transact(Native Method)
W/ActivityManager(  583):       at
android.app.ApplicationThreadProxy.scheduleUnbindService(ApplicationThreadNative.java:516)
W/ActivityManager(  583):       at
com.android.server.am.ActivityManagerService.removeConnectionLocked(ActivityManagerService.java:9609)
W/ActivityManager(  583):       at
com.android.server.am.ActivityManagerService.killServicesLocked(ActivityManagerService.java:8515)
...

Thank you.

谢谢你。

采纳答案by Dimitar Dimitrov

This means that your service had already stopped - either killed from the OS, or stopped from your application.

这意味着您的服务已经停止 - 要么被操作系统杀死,要么被您的应用程序停止。

Does this problem happen every time you debug your project?

每次调试项目时都会出现这个问题吗?

Override your service's onDestroy()method and watch what event flow leads to it. If you catch DeadObjectExceptionwithout going through this method, your service should have been killed by the OS.

覆盖您的服务的onDestroy()方法并观察导致它的事件流。如果DeadObjectException不通过此方法就捕获,则您的服务应该已被操作系统杀死。