If you want to load a package already installed in the system, it is
much easier to use Context.createApplicationContext().

On Apr 10, 2:05 am, "Carl H." <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You can use Dex file to load a class dynamically:
>
>                 DexFile df = new DexFile(new File(appDir));
>                 ClassLoader cl = getClassLoader();
>                 Class clazz = df.loadClass(dynClass, cl);
>
> appDir can be found using PackageManager if you wish so (eg: /data/app/
> MyPack.apk). dynClass is the class that you want to load. Be careful
> to ensure that the package name of the appDir is different then the
> one from where you are loading the class. You might want to create
> your own classloader. I will do so shortly and post it on somewhere
> online. Currently I don't really have time.
>
> Regards,
> Carl
>
> On Apr 10, 8:36 am, "David Welton" <[EMAIL PROTECTED]> wrote:
>
> > >  I want to develop an application, it was form by plugins.
> > >  Then I need to load a class from plugin.
> > >  Use Class.forName() to load a class from the same apk file, it's
> > >  successful, but if the class is in another apk file, the method throw
> > >  ClassNotFoundException.
> > >  How to load the class from another apk file?
>
> > If I may take a moment to blatantly promote my own work, another
> > solution might be to simply use an interpreter to dynamically load up
> > some text as code.  The interpreter being, in my case, Hecl
> > (www.hecl.org), although I'm sure there are either already others or
> > there will be soon.
>
> > --
> > David N. Welton
>
> >http://www.welton.it/davidw/
>
> >http://www.dedasys.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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