}
@Override
public void changePerson() throws RemoteException {
mPerson.setName(“CCCCCCC”);
Log.d(TAG, "changePerson: " + mPerson);
}
@Override
public void personChanged() throws RemoteException {
Log.d(TAG, "personChanged: " + mPerson);
}
@Override
public Person getPerson() throws RemoteException {
return mPerson;
}
}
findViewById(R.id.in).setOnClickListener(v -> {
try {
Person in = new Person(“In”, “1”);
Log.d(TAG, "in1: " + in);
mService.setPersonIn(in);
Log.d(TAG, "in2: " + in);
} catch (RemoteException e) {
e.printStackTrace();
}
});
findViewById(R.id.out).setOnClickListener(v -> {
try {
Person out = new Person(“Out”, “1”);
Log.d(TAG, "out1: " + out);
mService.setPersonOut(out);
Log.d(TAG, "out2: " +
《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享
out);
} catch (RemoteException e) {
e.printStackTrace();
}
});
findViewById(R.id.inout).setOnClickListener(v -> {
try {
Person inOut = new Person(“InOut”, “1”);
Log.d(TAG, "inOut1: " + inOut);
mService.setPersonInOut(inOut);
Log.d(TAG, "inOut2: " + inOut);
} catch (RemoteException e) {
e.printStackTrace();
}
});
从代码可以知道,我们分别定义了使用 in
,out
,inout
修饰的三个方法,然后在客户端分别调用了这三个方法,服务端则在收到对象后马上修改对象的属性。我们看一下运行起来的 Log,观察下数据流向。
============