0

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 it does not work. I think the problem is at the ClassPath. Does anyone have an idea?

Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
cojack
  • 59
  • 1
  • 4
  • Everything is in the same Project file !!!! – cojack Mar 16 '17 at 11:39
  • Possible duplicate of [How can I retrieve all classes that implement a custom interface?](http://stackoverflow.com/questions/42762240/how-can-i-retrieve-all-classes-that-implement-a-custom-interface) – kaqqao Mar 17 '17 at 12:22
  • When you say _it doesn't work on Android_ you're not saying _what doesn't work_. You get no results? You get an exception? What? – kaqqao Mar 17 '17 at 12:25

0 Answers0