get Declared Method - Android java.lang.reflect

Android examples for java.lang.reflect:Method Get

Description

get Declared Method

Demo Code


//package com.java2s;

import java.lang.reflect.Method;

import android.util.Log;

public class Main {
    public static Method getDeclaredMethod(Object object,
            String methodName, Class<?>[] parameterTypes) {
        Method method = null;/*w  w w .j  ava  2  s . c om*/

        for (Class<?> clazz = object.getClass(); clazz != Object.class;) {
            try {
                method = clazz
                        .getDeclaredMethod(methodName, parameterTypes);
                return method;
            } catch (Exception e) {
                Log.i("ReflectUtil File", "");

                clazz = clazz.getSuperclass();
            }

        }

        return null;
    }
}

Related Tutorials