In java (NetBeans) i realized it with...
ClassPathLoader pathLoader = new ClassPathLoader(".");
try {
//get Classes
Hashtable ht = pathLoader.getClasses();
Set s = ht.keySet();
Iterator iter = s.iterator();
String fullName = null;
while(iter.hasNext()) {
try {
fullName = (String) iter.next();
//create class
Class cls = Class.forName(fullName);
//get interface from the class
Class[] interfaces = cls.getInterfaces();
for(int i = 0; i < interfaces.length; i++) {
if(interfaces[i].getName().equals("IMyObserver.IFeature")) {
//Field field = cls.getDeclaredField("LOCATION");
//String location = (String)field.get(null);
Constructor cons2 = cls.getDeclaredConstructor(List.class);
Object oo = cons2.newInstance(qList);
System.out.println(fullName);
}
}
This works very well, but in android does not work. I think the problem is at the ClassPath... ?!?! have anyone a idea? thx
Aucun commentaire:
Enregistrer un commentaire