[英]How to implement hidden interface with reflection in android JAVA?
I would like to use android.filterfw.* framworks in android 4.0 later. 我想稍后在android 4.0中使用android.filterfw。* framworks。 but, it is still hidden in SDK. 但是,它仍然隐藏在SDK中。 so, now I am trying JAVA reflection-tricks. 所以,现在我正在尝试JAVA反射技巧。
do anyone know how to implement hidden interface with reflection in android JAVA ? 有谁知道如何在Android JAVA中使用反射实现隐藏接口?
I want to mimic the following code with reflection. 我想用反射模仿以下代码。
private SurfaceTextureSourceListener mSourceReadyCallback = new SurfaceTextureSourceListener() {
public void onSurfaceTextureSourceReady(SurfaceTexture source) {
}
};
mGraphEnv.addReferences("textureSourceCallback", mSourceReadyCallback);
I did this one. 我做了这个。
Class c = Class.forName("android.filterpacks.videosrc.SurfaceTextureSource$SurfaceTextureSourceListener"); //step 1
instance = c.newInstance(); //step 2
proxy = Proxy.newProxyInstance(instance.getClass().getClassLoader(), new Class[] { instance.getClass() }, mHandler); //step 3
InvocationHandler mHandler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//TODO
return method.invoke(instance, args);
}
};
then, I got an exception on "step 2". 然后,我在“步骤2”上遇到了异常。 OK, I understand I can't create an instance of interface directory. 好的,我知道我无法创建接口目录的实例。 so, my question is how to implement hidden interface with reflection. 因此,我的问题是如何使用反射实现隐藏接口。
I can not do something like this... 我不能做这样的事情...
public class MyIPL implements SurfaceTextureSourceListener {
}
do you know any ideas ? 你知道什么主意吗?
阅读此隐藏的API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.