Android Question [SOLVED] Check if method exists

wonder

Expert
Licensed User
Longtime User
Hi!

Since Try/Catch doesn't work with CallSub, is there a way to check if a method exists in a given class (instance)?

Edit: Solved!
B4X:
Sub SafeCallSub(class As Object, method As String) As Object
    If SubExists(class, method) Then Return CallSub(class, method)
    Return Null
End Sub
 
Last edited:

wonder

Expert
Licensed User
Longtime User
Yes. SubExists.

Better to use XUI.SubExists if you are writing cross platform code.
OMG!!! The solution was right in front of me and I was meddling with Reflection and JavaObject all the time!! :p

Thank for the quick answer and sorry for wasting your time with such a trivial question. :)
 
Upvote 0
Top