I am trying to use reflection to invoke a method of Resources$Theme class but I am not able to do so.
Below is my code
Class inner=Class.forName("android.content.res.Resources$Theme");
Constructor []ins=inner.getConstructors();
// Method met=inner.getDeclaredMethod("newTheme", null);
Method [] mer=inner.getMethods();
for(Method m:mer){
String name=m.getName();
System.out.println(name);
}
// Object obj= met.invoke(null, null);
for(Constructor con:ins){
String name=con.getName();
System.out.println(name);
}
On Checking theme class I can see that newTheme(),getTheme and default constructor is available. When I enable the first commented line it gives me error as NoSuchMethodFoundException. So tried to get all method name from class and I saw that it does not contain the few methods like newTheme(),getTheme(). Also my constructor list is coming as empty.
Can someone explain the reason behind it. I saw that one of the method(newTheme) is final and other(getTheme) has one annotation ( @ViewDebug.ExportedProperty(category = "theme", hasAdjacentMapping = true) . Is it because of this? If yes then what does the annotation means? Also why I do not see constructor list even when constructor is defined with /package/ preceding. What does /package/ means here?
Aucun commentaire:
Enregistrer un commentaire