mercredi 9 février 2022

NoSuchMethodException was thrown when using reflection in Android

Suppose I have two interfaces IUserManager and BBBB declared under package android.os:

package android.os;

public interface IUserManager  {
    void foo();
}
package android.os;


public interface BBBB {
    void foo();
}

Suppose I hope to use refection to get the foo methods defined in them:

line 1: BBBB.class.getDeclaredMethod("foo", new Class[] {});
line 2: IUserManager.class.getDeclaredMethod("foo", new Class[] {});

Why an exception java.lang.NoSuchMethodException: android.os.IUserManager.foo [] is thrown at line 2?





Aucun commentaire:

Enregistrer un commentaire