Android Method Invoke invokeMethod(Object object, String methodName, Object[] params, Class... types)

Here you can find the source of invokeMethod(Object object, String methodName, Object[] params, Class... types)

Description

invoke Method

Declaration

private static Object invokeMethod(Object object, String methodName,
            Object[] params, Class... types) throws Exception 

Method Source Code

//package com.java2s;

import java.lang.reflect.Method;

public class Main {
    private static Object invokeMethod(Object object, String methodName,
            Object[] params, Class... types) throws Exception {
        Object out = null;//from www . ja v a 2  s  .c om
        Class c = object instanceof Class ? (Class) object : object
                .getClass();
        if (types != null) {
            Method method = c.getMethod(methodName, types);
            out = method.invoke(object, params);
        } else {
            Method method = c.getMethod(methodName);
            out = method.invoke(object);
        }
        //System.out.println(object.getClass().getName() + "." + methodName + "() = "+ out);
        return out;
    }
}