Android proxy/delegate application Framework (mainly introduction to plug-in development)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.