Research on the development of Android plugin--analysis

Source: Internet
Author: User

To undertake the development of Android plugin above--Basic
http://blog.csdn.net/yzzst/article/details/45582315

By using Dexclassloader, we are able to dynamically load classes in Classes.dex into the current process. Of course, you can pre-set some agent interface to complete the functions of the four components.

整体功能如所示:

Of course, for an Android application, it's not enough to just dynamically load classes and declare four components. As shown, let us often see an apk file extracted after the contents of the file.

Those of you who have developed Android projects should not be particularly unfamiliar with this directory, because it is very similar to the development environment when we develop Android applications. However, the extracted files after all is not the source code, we can not directly read and modify. For each of these folders and files, describe the following:

 - assets                       声音、字体、网页...资源, - org                          带三方库,如org.apache.http库 - com                      带三方库,不解释 - lib                          应用中使用到的native库 - armeabi                  .so文件,c/c++代码库文件 - META-INF                 APK的签名文件【***.RSA、***.SF、***.MF三个文件 】 - res                          应用中使用到的资源目录 - AndroidManifest.xml          应用的属性定义文件 - classes.dex                  Java源码编译后的代码文件 - resources.arsc               编译后的资源文件

This is the same for our plug-in installation, from the directory we can see, if we need to make a plug-in framework. In addition to using Classdexloader parsing to load Classes.dex, from a normal apk installation process
We also need to deal with several issues:

    • Plug-in signature check

    • Install the native library, which completes calls to Java class and C + +

    • Handles Androidmanifest.xml, dynamically declares different components/permissions/broadcasts/Services/theme

    • Storing files such as Shreadpreference/sqlite/cache

    • Plugin Uninstall

    • The function of the host with plug-ins, plug-in callback host code

    • Mutual invocation of functions between multiple plugins

Only through the completion of the above issues, we can think of this framework is a more reasonable plug-in framework, otherwise it can only be considered a dynamic start activity process.

/*
* @author Zhoushengtao (Zhou San)
* @since January 27, 2015 14:02:22
* @weixin stchou_zst
* @blog http://blog.csdn.net/yzzst
* @ Exchange Learning QQ Group: 341989536
* @ Private qq:445914891
/

Research on the development of Android plugin--analysis

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.