IntentService 中的 RemoteException

RemoteException in IntentService

我的 IntentService 中有以下代码,用于向注册客户发送 Message

for(Messenger client : clients) {
    client.send(aMessage);
}

根据send()的文档,这个方法可以抛出一个RemoteException,具体是一个DeadObjectException

来自 DeadObjectException 的文档:

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

如果我理解正确,这意味着如果我的客户都来自 Service 的流程,(理论上)这个 Exception 永远不会 被抛出。

我说的对吗?

提前致谢。

是。
但需要注意的是,Messenger 的全部目的是与官方文档中提到的不同进程进行通信:

If you need your service to communicate with remote processes, then you can use a Messenger.

如果您需要在同一进程中与您的服务进行通信,我建议您使用 local bound service