Development of Android plug-ins-analysis and preliminary exploration of android plug-ins
Undertake the aboveDevelopment of Android plug-ins-Basics
Http://blog.csdn.net/yzzst/article/details/45582315
By using DexClassLoader, We can dynamically load the classes in classes. dex into the current process. Of course, you can set some proxy interfaces in advance to complete the functions of the four major components.
Shows the overall function:
Of course, for an Android application, it is not enough to dynamically load the class and declare the four main components. As shown in, it is common to use an APK file to decompress the file content.
If you have developed an Android project, you will not be familiar with this directory, because it is very similar to the development environment when we develop Android applications. However, after all, the extracted files are not source code and cannot be directly read or modified. Each folder and file is described as follows:
-Assets sound, Font, webpage... resources,-org with third-party libraries, such as org. apache. the http library-com contains a third-party library. It does not explain the native library-armeabi. so file, c/c ++ code library file-META-INF APK signature file 【***. RSA ,***. SF ,***. MF files: the Resource Directory used in the res application-AndroidManifest. xml application attribute definition file-classes. dex Java source code compiled code file-resources. resource file compiled by arsc
This is the same for our plug-in installation. We can see from the directory that if we need to build a plug-in framework. In addition to using ClassDexLoader to parse and load classes. dex
We also need to solve several problems:
Plugin Signature Verification
Install native library to call Java Class and C/C ++.
Process AndroidManifest. xml and dynamically declare different components/permissions/broadcast/service/Theme
Store files such as ShreadPreference, SQLite, and cache
Plug-in uninstall
The host calls the plug-in function and calls back the code of the host.
Mutual function call between multiple plug-ins
Only after completing the above issues can we regard this framework as a reasonable plug-in framework, or it can be regarded as a process of dynamic Activity startup.
/*
* @ Author zhoushengtao (Zhou Shengtao)
* @ Since 14:02:22, January 1, January 27, 2015
* @ Weixin stchou_zst
* @ Blog http://blog.csdn.net/yzzst
* @ Exchange and learning QQ group: 341989536
* @ Private QQ: 445914891
/