Use
Android : Shareduserid = "Com.wallj.skin"
1, a total of three projects, the package name is Com.wallj.main/com.wallj.spring/com.wallj.summerOne of the main projects Com.wallj.main, the other two for the plug-in project, are only the main project to provide resources. Three projects require the use of the sameandroid:shareduserid= "
Com.wallj.skin "To achieve the purpose of resource sharing.
When this property is set, ClassLoader between three projects can access resources from one another. (This property is sometimes used to share the UID of the system in order to give the app root privileges, but it needs to be supported by the system)
2, in the Com.wallj.main project throughDexclassloader Loads the plugin's Dex and determines whether its shareduserid is consistent with the main project. or a plugin installed as a standalone app, you can also use other Packagemanager to get the app's package information from the installed list before judging whether Shareduserid is consistent with the main project.
3, the judgment is unanimous, should be already got the package name and so on application information, Then can be loaded through the reflection of the R.java, according to R.java get the resource file ID, through the package name and other information to get the application's context information, using the context and resource ID can find the resource file (for example: Picture resources), get the resource file can be arbitrary.
If you do not want to use the resource file, but want to invoke the class, and start the activity in it, it should be only in the second step, to load the desired class file, but the activity is not new, this is a problem.
Specific details have not been practiced, here only to record the JVM and Dalvik to the class unique recognition is ClassLoader ID + packagename + ClassName, so a running program is possible there are two package names and class names exactly the same class.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Plugin Research