For a long-term student project, i'm trying to develop a modular application with plugins. Specifically, we would have:
A master application where we could search, update, delete and run the plugins. This master application would also store some data from plugins.
Several plugins downloaded from a HTTP server with code and GUI components.
For now, i have a master application which is able to download a .apk file from HTTP and to create a new instance from a class defined in this .apk file. I use the way described here: http://android-developers.blogspot.fr/2011/07/custom-class-loading-in-dalvik.html with the DexClassLoader() method.
But i'm unable to see how to display a layout (or any other GUI component) stored as a resource in the plugin .apk file. For instance, i tried without success to create an Intent from the master application by using the plugin classname:
DexClassLoader cl = new DexClassLoader(...);
Class<?> libClass = cl.loadClass("plugin_classname");
Intent intent = new Intent(this.getApplicationContext(), libClass);
startActivity(intent);
And this doesn’t work because the Intent is not declared in the AndroidManifest.xml of the master application. This is also described in this other thread: Android- Using DexClassLoader to load apk file
Does that mean that there is absolutely no way to build a such "dynamic" user interface? More generally, can this type of plugin system be done on Android? Should i try an other method?
plugin.jar
. The jar that implements the interface? I have a jar built by eclipse withclasses.dex
entry but theloadClass
always throws an exception. – Kalie