Skip to content

Instantly share code, notes, and snippets.

@abrahammartin
Last active January 3, 2016 05:49
Show Gist options
  • Select an option

  • Save abrahammartin/8418629 to your computer and use it in GitHub Desktop.

Select an option

Save abrahammartin/8418629 to your computer and use it in GitHub Desktop.
Know all the methods of a class in runtime (Android). Reflection.
Method[] listofMethods = NameOfClass.class.getMethods();
for(Iterator<Method> i = Arrays.asList(listofMethods).iterator(); i.hasNext(); ) {
Method method = i.next();
Log.d(TAG, "Method name: " + method.getName());
Class[] params = method.getParameterTypes();
for(Iterator<Class> j = Arrays.asList(params).iterator(); j.hasNext(); ) {
Class param = j.next();
Log.d(TAG, "Method params for method "+method.getName()+": "+param.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment