Is it possible to load activities from an external dex-file? I’m thinking of some plug-in style-architecture, where an application can be extended by downloading dex-files with activities and classes containing extra functionality.
I’ve managed to load and invoke methods on a class from a downloaded dex-file using DexClassLoader and reflection. But could I somehow use this technique to download and present an Activity? Is it possible to register this new Activity programmatically so that I can invoke it using an Intent?
I know that it’s possible (and the recommended way is) to install the other Activity through the normal procedure with an APK, and then load it from my main activity using Intents or simply update the installed application, but I want to extend my already installed application by downloading some extra classes and execute everything in the same VM, same sandbox.
Hm, let me know if you don’t understand what I mean, cause this got a bit messy.. 🙂
Not exactly. Activities must be pre-defined in the application’s manifest.
You can try to use the approach that JRuby and Ruboto use, where there is one activity in the manifest that gets repurposed with different implementations. I haven’t dissected their approach fully, but I am under the impression that their activity forwards events to a JRuby script. In your case, the activity would forward events to some other class loaded from the DEX file.