Android Question [ANSWERED] What library defines type "Method" ?

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Such as returned by Reflector.GetMethod

FWIW: I find this type of question to be a challenge with B4A. It is not stated in the reflection library documentation, nor the book I bought. There is no really effective way to search online examples for use of GetMethod that I have been able to come up with. Everyone just seems to know this. Please enlighten me if I am missing something. In the Java/Android or C++ or C# world, and in the Visual Studio world this is never an issue for me.
 

Roycefer

Well-Known Member
Licensed User
Longtime User
The Reflector library defines the Method object. If you need to store it in a variable, store it in a variable of type Object.

That's one of the fun tidbits of Java: due to polymorphism and inheritance, everything (except primitives) is of type Object and can be stored in a variable of type Object.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Maybe I have misinterpretted your question but I also struggle to find which methods are available and I've been confused in the past because I was unable to access a method I knew existed. If I recall correctly it was something to do with determining the position of a track that was being streamed and it turned out that I couldn't access the method because I was using a library which wrapped the original class (or something like that), but I digress. Whenever I need to look up things like this I search the Android Developer site, this is also the first place to go when wanting to know what themes and styles are available by default. I'm sure your already aware of this but I'll post it incase others find it useful... http://developer.android.com/reference/packages.html
I'd love to know how others seem to find the information they need with such ease, it takes me an age to find what I want! :(
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
I think what is confusing for me (in this case) is that GetField is documented as
GetField (field As String) As Object
whereas GetMethod is documented as
GetMethod (method As String, types() As String) As Method
and also we see it again here....
InvokeMethod (instance As Object, method As Method, args() As Object) As Object
implying GetField returns a value can be held in a variable of type object, and GetMethod is returning a type that can be declared in B4A. I guess the only thing you can do with a "method" held in an Object is for a call to InvokeMethod. But still a sidebar of some sort saying there is no actual "Method" type would be helpful information saving hours spent chasing something that is not there.
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
There is a Method type, you just can't declare an instance of it in B4X. But you can still store an instance of it in an Object type.

This is where B4X's code completion comes in handy; it will tell you whether or not a specific type can be instantiated or not.
 
Upvote 0
Top