No Such Method Exception - Using Reflection
I'm trying to use reflection (on an android app) to invoke a method and it work only when I do it this way Object impresora = loadedClass.newInstance(); Object args[] =
Solution 1:
In your first snippet you're doing object.getClass()
in your second snippet you're doing impresora.getClass()
.
Solution 2:
You need the actual parameter types in order to find the methods otherwise it will try to look for the method without an argument which I am guessing doesn't exist in your class.
Seeing:
Object args[] = {"00:15:0E:E0:DD:38", true};
I am guessing that the first argument is a String and second one is a boolean, so in order to find the method you need to do the following:
Method m = c.getDeclaredMethod("BTConnection", String.class, Boolean.class);
Post a Comment for "No Such Method Exception - Using Reflection"