Android examples for java.lang.reflect:Method Invoke
invoke Method For Float
//package com.java2s; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static float invokeMethodForFloat(Class invokeClass, String methodName, Object paramObject) { Method method;/*from ww w. java 2 s .c o m*/ try { method = invokeClass.getDeclaredMethod(methodName); method.setAccessible(true); return ((Float) method.invoke(paramObject, null)).floatValue(); } catch (IllegalArgumentException localIllegalArgumentException) { localIllegalArgumentException.printStackTrace(); return 0f; } catch (IllegalAccessException localIllegalAccessException) { localIllegalAccessException.printStackTrace(); return 0f; } catch (InvocationTargetException localInvocationTargetException) { localInvocationTargetException.printStackTrace(); } catch (NoSuchMethodException noSuchMethodException) { noSuchMethodException.printStackTrace(); } return 0f; } }