Last active
January 3, 2016 05:49
-
-
Save abrahammartin/8418629 to your computer and use it in GitHub Desktop.
Know all the methods of a class in runtime (Android). Reflection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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