如何从不同的 .apk 连接到远程服务
首先,我看到了这个:
它根本没有帮助我。这是交易。我有一个创建远程服务的 apk(称之为 A)。然后我有另一个 apk(称之为 B)。如何在不包含 AIDL 文件或 jar 文件的情况下将 B 连接到 A。我认为这是可能的。
** 更新 **
因此,我已将 AIDL 文件复制到 B 中,并在 A 中为 AIDL 文件创建服务。我现在可以连接到远程服务并绑定到该服务。但是,当我尝试调用服务中存在的方法时,我得到:
java.lang.SecurityException: Binder 调用到不正确的接口
无法找到任何有关此问题的帮助。有什么想法吗?
** 问题已解决 ** AIDL 文件必须位于项目 B 中同名的包中。感谢 Peter 的帮助。
First off I have seen this:
And it does not help me at all. Here is the deal. I have one apk that creates a remote service (call it A). I then have another apk (call it B). How can I connect B to A without include the AIDL file or a jar file. I would think that this would be possible.
** UPDATE **
So I have copied the AIDL file into B and created an to the service in A for the AIDL file. I can conntect to the remote service, and bind to the service now. However when I try to call a method that exists in the service I get:
java.lang.SecurityException: Binder invocation to an incorrect interface
Having trouble finding any help on this. Any ideas?
** PROBLEM SOLVED **
The AIDL file had to be in a package with the same name in the project B. Thanks for your help Peter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须知道在两个单独的进程之间发送的数据的格式。这是将数据序列化/反序列化为 Java 对象所必需的。
AIDL是一种描述对象结构的描述语言。
因此,您有两个选择:
要么拥有 AIDL,要么
您的代码明确知道执行反序列化/序列化的格式。这是
Parcelable
的实现。此实现可以位于您的应用程序中包含的 jar 内。You have to know the format of the data that is sent between two separate processes. This is needed for serialization/deserialization of the data to Java objects.
AIDL is a description language to describe the structure of objects.
So, you have two options:
Either you have an AIDL, or
your code explicitly know the format to do the de-/serialization. This is the implementation of
Parcelable
. This implementation could be inside a jar that you include in your app.