I have met some tutorials on the web, which are invoking simple methods and all I n开发者_如何学编程eed is to invoke method "startDownload" which accepts Context as a parameter. I am now calling it:
Class<?> loaded = cl.loadClass("com.test.someclass");
Method m = loaded.getDeclaredMethod("startDownload", null);
m.invoke(this, null);
where c1 is DexClassLoader. But no success. I am getting error of NoSuchMethodException, I know I have to add parametres somewhere, but don't know where... any advices?
Thanks
I suggest looking at that post.
The parameters are passed after the method name when calling Class.getMethod(name, ...)
, as described here. You can directly use the class
member of the Class
you have to pass:
Method myMethod = myClass.getMethod("doSomethingWithAString", String.class);
Maybe you forgot some of them: the method won't be found if the signature (so the parameters) are not correct.
精彩评论