Android plug-ins
Use
Android: sharedUserId = com. wallj. skin
1. A total of three projects with the package names com. wallj. main/com. wallj. spring/com. wallj. in the summer, com. wallj. main is the main project, and the other two are plug-in projects, which only provide resources for the main project. The three projects must use the same android: sharedUserId =
Com. wallj. skin to share resources.
After this attribute is set, the ClassLoader between the three projects can access resources from one another. (Sometimes this attribute is used to share the system uid to give the app the root permission, but it must be supported by the system)
2. In the com. wallj. main project, use DexClassLoader to load the dex plug-in and determine whether its sharedUserId is consistent with that of the main project. You can also use other packageManager to obtain the package information of the application from the installed list, and then determine whether the sharedUserId is consistent with the master project.
3. After the consistency is determined, the application information such as the package name should have been obtained, and then the R can be loaded through reflection. java, according to R. java obtains the resource file id and the context information of the application through the package name and other information. You can use the context and resource id to find the resource file (for example, image resource ), after obtaining the resource file, you can do whatever you want.
If you do not want to use the resource file, but call the class in it, and start the Activity in it, it should be only in step 2, to load the class file you want to use, but the Activity cannot be new. This is a problem.
The specific details have not been put into practice. Here we only record JVM and Dalvik's unique identification of classes is ClassLoader id + PackageName + ClassName, therefore, a running program may have two classes with the same package name and class name.