Just wanted to add that I get false for following line even if I have
annotation added.
if (methodList[i].isAnnotationPresent(MethodInfo.class))

On May 12, 5:05 pm, Nehal <[email protected]> wrote:
> Hello,
> I am trying to use annotation - method.getAnnotation( ) or
> method.isAnnotationPresent( ) and it is not working.
>
> I am using eclipse emulator for 2.1 OS version with JDK 1.6. Following
> is information about what I did. Please advise if I am doing something
> wrong.
>
> 1) Added annotation type
> public static final int METHOD_UNDEFINED = -1;
>
>         public @interface MethodInfo {
>                 int id() default METHOD_UNDEFINED;
>         }
>
> 2) Added annotation for my method
> final public static int METHOD_TESTMSG = 1;
>
> @MethodInfo(id=METHOD_TESTMSG)
> public void testMsg(String msg, int data1, boolean bool1) {
> // code here
>
> }
>
> 3) Now I am trying to find this method using annotation.
> Method [] methodList = instanceClass.getDeclaredMethods();
>                 for(int i=0; i< methodList.length; i++) {
>                         if 
> (methodList[i].isAnnotationPresent(MethodInfo.class)) {
>                                 // stuff here
>                         }
>                 }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to