server端的实现
1.创建 aidl文件 (例如ICatl.aidl)
2。创建一个server 并在server中创建一个内部类,继承aidl文件的stub例如:
public class AidlService extends Service {
private CatBinder catBinder;
//此处要继承Stub,实现ICat和IBinder接口
public class CatBinder extends ICat.Stub
{
@Override
public String getColor() throws RemoteException {
//这里做一些操作,获得客户端想要的数据,例如查询数据库
return "red";
}
@Override
public double getWeight() throws RemoteException {