【发布时间】:2019-08-20 01:49:12
【问题描述】:
使用代理对象实现 AIDL 接口
Class studyManager = Class.forName("StudyManager");
Class iStudyCallbackClient = Class.forName("IStudyCallbackClient");
Method setTouchCallback = studyManager.getDeclaredMethod("setTouchCallback", iStudyCallbackClient);
Proxy proxy = (Proxy) Proxy.newProxyInstance(iStudyCallbackClient.getClassLoader(),
new Class[] { iStudyCallbackClient }, new IStudyCallbackClientImpl());
setTouchCallback.invoke(studyManager.newInstance(), proxy);
class IStudyCallbackClientImpl implements InvocationHandler {
@Override
public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
Log.d(TAG, method.getName());//why here is asBinde() not sendPoint()?
return null;
}
AIDL
interface IStudyCallbackClient {
void sendPoint(int x,int y);
}
问题:
代码运行正常。
当调用回调函数(IStudyCallbackClient.sendPoint(int x,int y))时,
为什么 method.getName() 是 asBinder?而不是 sendPoint()?
【问题讨论】:
标签: java android dynamic-proxy