Hello everyone,

I've already managed to load a single class from anothers application
context:
--- code ---
Context foreignContext = context.createPackageContext(packageName,
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
Class<?> c =
foreignContext.getClassLoader().loadClass(qualifiedClassName);
//Do things with c
--- code ---

What I would like to do now, is to load all the classes contained in a
certain package
--- code ---
ClassLoader cld = foreignContext.getClassLoader();
String packagePath = "name.to.a.package".replace('.', '/');
URL resource = cld.getResource(packagePath);
File packageDirectory = new
File(URLDecoder.decode(resource.getPath(),"UTF-8"));
//iterate over the contents of the packageDirectory
--- code ---

The above code works perfect in Java SE 1.5 (For testing in standard
Java I use the Thread.currentThread().getContextClassLoader() instead
of Androids-Context ClassLoader)
But Android always gives me an exception because resource (URL) is
null.
I also tried providing the package-path differently, with e.g.
the .apk-path as prefix, but that doesn't work either.
>From the doc of Classloader in Android, I've seen that the default
behaviour of getResource() is to return null.
This is something the Java SE doesn't state.
Does this mean I can't use Classloader.getResource() in Android?

What else could I do to get all classes of a package in Android? -
Load the dex-File?
Any suggestion is greatly appreciated! - Thanks chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to