Android plug-ins

Source: Internet
Author: User

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.

 

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.