Hi devs
Can anyone tell me how to resolve all classes in diffirent package?
Here is java code to resolve but I don't know how to use it
Like that or so:
Thanks in advance
Can anyone tell me how to resolve all classes in diffirent package?
Here is java code to resolve but I don't know how to use it
B4X:
#If JAVA
import java.util.ArrayList;
import java.io.File;
public static Class[] getClasses(String pckgname) throws ClassNotFoundException {
ArrayList classes=new ArrayList();
File directory=null;
try {
directory=new File(Thread.currentThread().getContextClassLoader().getResource('/'+pckgname.replace('.', '/')).getFile());
} catch(NullPointerException x) {
throw new ClassNotFoundException(pckgname+" does not appear to be a valid package");
}
if(directory.exists()) {
String[] files=directory.list();
for(int i=0; i<files.length; i++) {
if(files[i].endsWith(".class")) {
classes.add(Class.forName(pckgname+'.'+files[i].substring(0, files[i].length()-6)));
}
}
} else {
throw new ClassNotFoundException(pckgname+" does not appear to be a valid package");
}
Class[] classesA=new Class[classes.size()];
classes.toArray(classesA);
return classesA;
}
#End If
Like that or so:
B4X:
Dim jo As JavaObject
jo.InitializeStatic(?)
Dim Classes as List = jo.RunMethod("getClasses", Array As String("android.telephony.TelephonyManager"))
Thanks in advance