【发布时间】:2019-04-15 09:16:06
【问题描述】:
在 Android 官方 Aidl 文档中,IPC 客户端示例以“RemoteService.class”为目标明确声明了一个意图。但是,当服务器和客户端不在同一个包中时,如果没有设置依赖项,客户端不应该知道什么是“RemoteService”。这个例子是如何工作的?
参考:https://developer.android.com/guide/components/aidl.html
我搜索了几个工作示例,意图是使用 Action 而不是远程服务类对象设置的。
在 Android 文档中,
Intent intent = new Intent(Binding.this, RemoteService.class);
intent.setAction(IRemoteService.class.getName());
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
目前,我希望这应该修改为:
Intent intent = new Intent("<remote-service-intent-filter-in-androidmanifest>");
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
【问题讨论】: