get Annotation Value With Name - Android java.lang.reflect

Android examples for java.lang.reflect:Annotation

Description

get Annotation Value With Name

Demo Code


//package com.java2s;
import java.lang.annotation.Annotation;

public class Main {
    public static Object getAnnotationValueWithName(Annotation annotation,
            String valueName) {//  w  w  w . j ava2 s.  co  m
        try {
            return annotation.annotationType().getMethod(valueName)
                    .invoke(annotation);
        } catch (Exception e) {
            return null;
        }
    }
}

Related Tutorials