在AIDL的Service意外断开之后,仍然去调用binder的方法,这个时候就会报一个错误:
System.err: android.os.DeadObjectException
W System.err: at android.os.BinderProxy.transactNative(Native Method)
W System.err: at android.os.BinderProxy.transact(BinderProxy.java:550)
W System.err: at com.voyah.btphonesdk.btphone.ISyncPhonebookCallback$Stub$Proxy.onCallAdded(ISyncPhonebookCallback.java:336)
W System.err: at com.voyah.btphone.service.BtPhoneService$3.onCallAdded(BtPhoneService.java:562)
W System.err: at com.voyah.btphone.view.dial.PhoneManagerIml.onCallAdded(PhoneManagerIml.java:552)
W System.err: at com.voyah.btphone.service.InCallServiceImpl$1.onStateChanged(InCallServiceImpl.java:150)
W System.err: at android.telecom.Call$1.run(Call.java:2506)
W System.err: at android.os.Handler.handleCallback(Handler.java:938)
W System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
W System.err: at android.os.Looper.loop(Looper.java:223)
W System.err: at android.app.ActivityThread.main(ActivityThread.java:7664)
W System.err: at java.lang.reflect.Method.invoke(Native Method)
W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
所以你需要在onServiceDisconnected或者onBindingDied方法里重新调用bindService来绑定服务,并且要弄清楚这个服务为什么会挂掉。
- RemoteCallBackList
当通过AIDL向服务端注册CallBack的时候,不要直接使用List,用RemoteCallBackList替代。
0 条评论