Add custom member methods for open classes for Android

Source: Internet
Author: User

Some Java classes in the android SDK are open, some are not open, and the same is true for APIs. The so-called open classes or APIs here are only the scope of javadoc and are not public and private in Java. That is to say, it does not matter for source code compilation, but it has an impact on upper-layer applications of Android, android upper-layer applications cannot directly access non-open classes or APIs.

Whether the class or API is open is controlled by the doc comment {@ hide. For example, android. media. metadata is a class that is not publicly available for Android, because in frameworks \ base \ media \ libmedia \ metadata. in the Java file, there is/** {@ hide} */This Doc comment before defining the metadata class. Therefore, the metadata class is defined as a non-public class, that is, in the Android ApplicationProgramClass that cannot be accessed directly.

However, if we add custom member methods or member variables to the Open Class of Android, the modified SDK (jar package) will be generated for upper-layer applications, this problem occurs during the process of compiling the source code to generate the SDK:
******************************
You have tried to change the API from what has been previusly approved.
To make these errors go away, you have two choices:
1) You can add "@ hide" javadoc comments to the methods, etc. Listed
In
Errors abve.
2) You can update current. xml by executing the following commands:
P4 edit frameworks/base/API/current. xml
Make Update-API
To check in the revised current. XML, you will need owners
Approval.
******************************
Google provides two options:
1. Add the javadoc annotation @ hide before the API or variable you added. However, it should be noted that you do not simply write @ hide or/* @ hide */. These are all incorrect javadoc annotation formats, the standard javadoc is like this/***/and the format variable should be added {}.
So we should write/** {@ hide} */like this }*/

2. This method or variable appears in the javadoc you want to generate. You must enter:
Make Update-API

However, if the modified class is not opened by Google, such as RIL and phonefactory, this problem will not occur,

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.