Android Question [SOLVED] Check if method exists

Discussion in 'Android Questions' started by wonder, May 20, 2019.

  1. wonder

    wonder Expert Licensed User


    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!
    Sub SafeCallSub(class As Object, method As StringAs Object
    If SubExists(class, method) Then Return CallSub(class, method)
    Return Null
    End Sub
    Last edited: May 20, 2019
  2. Erel

    Erel Administrator Staff Member Licensed User

    Yes. SubExists.

    Better to use XUI.SubExists if you are writing cross platform code.
    MarkusR and wonder like this.
  3. wonder

    wonder Expert Licensed User

    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. :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice