I have done a framework that works like Robo-guice with some of its primary IoC functions. (Cut down on boilerplate codes that load views/service etc...)
But the core of which, I believe is the solution to your problem, is the ability to load separate APK "plugin" files, that includes "res" as well as <layouts>.xml
files. The <layouts>.xml
file can be independently inflated by the classes within that APK. That is, you can load a CustomView (that inflates its own <layout>.xml
) into an originating/parent App. All this is done without the Parent App APK knowing how the UI was inflated in the plugin APK.
Example of what I mean:
I have a Mapping App, the framework will dynamically scan installed APK that matches the "contract" for a "add-on function" plugin, and loads the UI specific to it onto the App's View as a floating panel.
I would say a plugin framework for Android is do-able, as Android has most if not all of the necessary built in APIs to accomplish this.
These are your friends in this area of plugin development for Android:
- PackageManager (Scan install packages, aka Plugins)
DexClassLoader
(ClassNotFoundException
will be a pain if you don't use the correct ClassLoader
btw)
- Java Reflection
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…