使用aidl的Android远程服务

问题描述

| 我正在尝试使用Android AIDL在Eclipse中创建远程服务。我在/ src中创建了AIDL文件IRemoteService.aidl,如下所示:
package com.vtrandal.bluesentry;
interface IRemoteService {
    String getData();
}
完成构建后,我在/ gen中获得了一个巨大的文件IRemoteService.java,其中包含以下这些类和方法(它与我在文档中看到的内容不相似):
public interface IRemoteService extends android.os.IInterface

public static abstract class Stub extends android.os.Binder implements com.vtrandal.bluesentry.IRemoteService

private static final java.lang.String DESCRIPTOR = \"com.vtrandal.bluesentry.IRemoteService\";

public Stub()

public static com.vtrandal.bluesentry.IRemoteService asInterface(android.os.IBinder obj)

public android.os.IBinder asBinder()

public boolean onTransact(int code,android.os.Parcel data,android.os.Parcel reply,int flags) throws android.os.remoteexception

private static class Proxy implements com.vtrandal.bluesentry.IRemoteService

Proxy(android.os.IBinder remote)

public android.os.IBinder asBinder()

public java.lang.String getInterfaceDescriptor()

public java.lang.String getData() throws android.os.remoteexception

public java.lang.String getData() throws android.os.remoteexception;
那么,为什么IRemoteService.java包含这么多文档中未提及的垃圾?我怎么可能知道该怎么办?我怎么可能知道该怎么办?     

解决方法

这是服务存根代码。实际上需要与客户端进行通信。您自己没有编写任何用于在客户端和服务之间进行通信的代码,对吗?毕竟,它并不是那么简单,并且它正在为您生成。这就是为什么要编写这么多代码的原因。 并且文档通常讨论用户的API,而不是内部方法。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...