jeudi 9 mars 2017

android reflection method invoke -- what is a receiver


I'm trying to create a custom button method by creating a class that extends AppCompatButton. I have the process for locating the button method working
method = actClass.getMethod(methodName, View.class); where actClass is the class for the activity invoking the button. When I get to the code calling the method I get an exception:

Error = "expected receiver of type com.kana_tutor.button_demo.MainActivity,
but got java.lang.Class<com.kana_tutor.button_demo.MainActivity>"

I've tried using a class and an intent but neither works.

What is a receiver?
Method.java describes it as "@param receiver the object on which to call this method." Is this just a reference to the method I'm calling

I have the class the method lives in and its name. How can I create a "receiver?"
I haven't really needed to use reflection or invoke before.
Thanks!





Aucun commentaire:

Enregistrer un commentaire