How Android uses the hidden API (using the @hide API)

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_5da93c8f0101e1yj.html

The main thing this article introduces is to implement the use of the hidden API by importing the fully compiled Classes.jar package. This approach is simple and programmer programming is simple, just as the hidden APIs become visible in the SDK. Its disadvantage is the compatibility problem, I hope users pay attention to, in the use of a clear consideration.

method Two: Add Framework compiled out of Classes.jar files to Eclipse of the Build Path
actually in the compilation Android , we will Framework compile to a temporary Jar It's in the bag. Jar the path to the package is typically :
Out/target/common/obj/java_libraries/framework_intermediates/classes.jar
We only need to use the Make command under the Android source code directory on Linux to generate this file.

Since the API in this JAR file has not been repackaged, the API that was @hide out is not removed. So we can still quote the API that was @hide inside. While the Android.jar file in the SDK was repackaged and generated, the API labeled @hide was removed. So we copied the Out/target/common/obj/java_libraries/framework_intermediates/classes.jar to the local PC. Then add this jar package in the project.
Specific methods:
1. CopyLinuxcompile the generatedOut/target/common/obj/java_libraries/framework_intermediates/classes.jarto this machinePC.
2, inEclipseof theAndroidproject, select the project Properties->java Build path->libraries->add library->user library->next-> userlibrariesinto theUser Librariesmanagement interface, clickNewCreate a newUser Library, such asandroid_framework, clickADD JarsputJarpackage added to the establishedUser Libraryin the last clickOK.
3.Select Project Properties->java Build Path->order and Export, use the " up"Key, put the establishedUser Librariesmove toAndroid SDKthe top. This means that priority is given to usingClasses.jarin theAPI, followed by the useAndroid.jarin theAPI. Why not use it directlyclasses. Jar?because I found it when I was using it,Android.jarSome of the thingsClasses.jarnot in.

Practice

1. The first way to put the project code into the system source code, it can access all the API, I usually create a project in Windows Eclisp, after basic OK, the code system to compile, process placement path: pizza/package/apps/directory, Add a android.mk file, android.mk the contents of the file inside

local_path:=$ (call My-dir)
Include $ (clear_vars)
Local_module_tags:=optional
Local_src_files: = $ (call all-subdir-java-files)

# Depending on your project needs the APK name, no other need to modify
Local_package_name:=testremotesubmix
Local_certificate:=platform
Include $ (build_package)

2. The second way, do not need to remove @hide, that is, do not need to modify the Android system source code, directly out/target/common/obj/java_libraries/framework_intermediates/ Copy the Classes.jar file and add it to the Windows Eclisp as described above.

Note: It Classes.jar it contains the implementation of the specific method, in the standard SDK is no concrete method of implementation

How Android uses the hidden API (using the @hide API)

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.