360 Technical Team Address: http://blogs.360.cn/blog/proxydelegate-application/
Android Plugin Development, made dynamic load
About us Android Dex automatic unpacking and dynamic loading introduction
To achieve some special needs, such as interface skinning, plug-in, etc., we want to change the application of the operating environment (surrounding). For example, we want an app to run, all classes (including custom application, assuming it's called myapplication) to be loaded by a custom ClassLoader.
To implement this requirement, you need to replace the API layer's default ClassLoader before MyApplication is loaded, otherwise myapplication will be loaded by default ClassLoader. But this creates a paradox that no application code can run until MyApplication is loaded, and replacing ClassLoader cannot. Proxy/delegate application framework is used to solve this kind of problem.
In the Proxy/delegate application framework, a total of two application objects are applied, one called proxyapplication, and the other called Delegateapplication:
(1) proxyapplication: The framework provides a proxyapplication abstract class, which the user needs to inherit from and reload its initproxyapplication () method, in which change surrounding, such as replacement classloader, etc.
(2) delegateapplication: That is, the application of the original application, the application from Getapplicationcontext () and other methods are taken delegateapplication. Note that Delegateapplication is just a title, and there is not a base class called Delegateapplication exists.
Android proxy/delegate application Framework (mainly introduction to plug-in development)