public void setPersonOut(Person person) throws RemoteException {
Log.d(TAG, "setPersonOut1: " + person);
mPerson = person;
mPerson.setPrice(“666666”);
Log.d(TAG, "setPersonOut2: " + person);
}
@Override
public void setPersonInOut(Person person) throws RemoteException {
Log.d(TAG, "setPersonInOut1: " + person);
mPerson = person;
mPerson.setPrice(“666666”);
Log.d(TAG, "setPersonInOut2: " + person);
}
@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: " + 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
修饰的三个方法,