[Android] Android Engineering provides services to third-party applications in the form of jar packages

Source: Internet
Author: User

Reference: http://www.cnblogs.com/0616--ataozhijia/p/4094952.html

Take API 19 as an example:

The overall size of the system provided by default is: 21.8 MB Android.jar

After manually deleting the resource file, the Android.jar size is: 2.6 MB

from which you can determine: The jar package is the one that can be placed in the resource file

So how are the resources in the jar package called??

In pure Java mode: see reference

On Android: reference: http://blog.csdn.net/liguangzhenghi/article/details/8858544

1, jar is included in other projects, the resulting APK file contains the resources in the jar (the directory structure is the same), this can be opened by the zip jar and apk view.

2. The resource in the jar should also be managed by the JVM, but because its actual ID is inconsistent with the ID generated in the original Jar project, the resource ID in the original JAR project cannot be used to access the actual resource. Access can only be done by GetClass (). getClassLoader (). getResourceAsStream ().

For component development using the JAR approach, you need to be aware of the following:

1. The jar package typically contains only code that does not contain resources.

2. If you want to include resources in the jar, the resource files should not be placed in the default res directory (because there may be conflicting names after importing other items), you should create a dedicated resource directory under the package directory, so that the pakcage does not conflict with the names of the imported resources. At the same time, the code in the jar cannot be accessed directly using the resource ID in the R class, and should be loaded by GetClass (). getClassLoader (). getResourceAsStream ().

3. String resources can be defined as constants in the way they are used.

[Android] Android Engineering provides services to third-party applications in the form of jar packages

Related Article

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.