@@ -442,30 +442,34 @@ private static void runAnnotatedMethods(@NonNull Object object, int requestCode)
442
442
clazz = clazz .getSuperclass ();
443
443
}
444
444
445
- for (Method method : clazz .getDeclaredMethods ()) {
446
- if (method .isAnnotationPresent (AfterPermissionGranted .class )) {
447
- // Check for annotated methods with matching request code.
448
- AfterPermissionGranted ann = method .getAnnotation (AfterPermissionGranted .class );
449
- if (ann .value () == requestCode ) {
450
- // Method must be void so that we can invoke it
451
- if (method .getParameterTypes ().length > 0 ) {
452
- throw new RuntimeException (
453
- "Cannot execute method " + method .getName () + " because it is non-void method and/or has input parameters." );
454
- }
445
+ while (clazz != null ) {
446
+ for (Method method : clazz .getDeclaredMethods ()) {
447
+ if (method .isAnnotationPresent (AfterPermissionGranted .class )) {
448
+ // Check for annotated methods with matching request code.
449
+ AfterPermissionGranted ann = method .getAnnotation (AfterPermissionGranted .class );
450
+ if (ann .value () == requestCode ) {
451
+ // Method must be void so that we can invoke it
452
+ if (method .getParameterTypes ().length > 0 ) {
453
+ throw new RuntimeException (
454
+ "Cannot execute method " + method .getName () + " because it is non-void method and/or has input parameters." );
455
+ }
455
456
456
- try {
457
- // Make method accessible if private
458
- if (!method .isAccessible ()) {
459
- method .setAccessible (true );
457
+ try {
458
+ // Make method accessible if private
459
+ if (!method .isAccessible ()) {
460
+ method .setAccessible (true );
461
+ }
462
+ method .invoke (object );
463
+ } catch (IllegalAccessException e ) {
464
+ Log .e (TAG , "runDefaultMethod:IllegalAccessException" , e );
465
+ } catch (InvocationTargetException e ) {
466
+ Log .e (TAG , "runDefaultMethod:InvocationTargetException" , e );
460
467
}
461
- method .invoke (object );
462
- } catch (IllegalAccessException e ) {
463
- Log .e (TAG , "runDefaultMethod:IllegalAccessException" , e );
464
- } catch (InvocationTargetException e ) {
465
- Log .e (TAG , "runDefaultMethod:InvocationTargetException" , e );
466
468
}
467
469
}
468
470
}
471
+
472
+ clazz = clazz .getSuperclass ();
469
473
}
470
474
}
471
475
0 commit comments