getDeclaredMethodQuietly

fun getDeclaredMethodQuietly(className: String, methodName: String, vararg parameterTypes: Class<*>?): Method?

Finds a declared (private/protected) method of a class. If it's not found in the class, it will iterate through parents until it is found or there are no more parents.

Given a class: Thing(type: String)

Constructs via: val method = getDeclaredMethodQuietly("foo.bar.Thing", "attachBaseContext", listOf(Context::class.java))

Parameters

className
  • The full name of the class

methodName
  • The name of the method

parameterTypes
  • An array of Classes of the method parameters