How to Use hidden APIs in Android Application Development

Source: Internet
Author: User

At the beginning, it should be noted that, Google The reason API Hide @ Hide Marked Public Class, method, or constant. The major reason is that Android The system itself is still evolving. Slave 1.0 , 1.1 Coming soon Android 2.3.4 . These hidden API It may be unstable, so use hidden API , MeaningProgramPoor compatibility.


if you want to give me a suggestion, it is better not to use the hidden API . However, sometimes to implement Android apply some special functions or effects, hidden API can often play an unexpected role. API I will not give an example of what I can do here. If you do not know how to hide API if you can do anything, give up using them as soon as possible ......


if you don't want to give a long story, go to the topic. Hide API there are two main methods: first, in JAVA learning reflection mechanisms the reflection method mentioned in the article is hidden API ; second, use the fully compiled jar package classes. jar .


the reflection method is not described here, for details, see JAVA learning reflection mechanisms Use the reflection mechanism to hide API the method is flexible, exceptions can be captured in incompatible systems, so that programs do not crash. The disadvantage is that the process is too complicated and it is difficult to implement inheritance of hidden classes. If you need to hide a large number of API using reflection will undoubtedly leave programmers bored.


This Article mainly introduces the fully compiled classes. jar package, API . This method is easy to implement, and programmers are easy to program, just like the hidden API in SDK changed to be visible. Its disadvantage is its compatibility. We hope users will pay attention to it and take it into consideration.


compile Android after the Framework source code, out folder, out" target "common" OBJ "java_libraries" framework_intermediates " In the path, the fully compiled jar library classes. jar . All you need to do is set jar import the library to your project.


Import classes. jar in the process, there may be two problems (I am using eclipse development environment, so only the problems encountered in this environment are described ).


Problem 1: import otherJarTo import thisJarLibrary, found that the compilation is slow, sometimes even unable to compile successfully,EclipseCrash or prompt" Java. Lang. outofmemoryerror: Java heap Space " Error. This problem may be causedJarThe reason is too big. Eclipse. ini I tried the parameters in, but it does not seem helpful. My approach is Eclipse To create a custom Library , And then Classes. Jar Put in Library . Android Add Project Library , Just like using SDK Same. This can solve this problem well. How to create a custom Library I will not elaborate on it. It is very easy for a friend who does not know to search for or explore it by himself.


Problem 2: The data has been correctly imported. Jar Library, but found that the hidden API . This is because Build class path order No, specifically Android. Jar And Classes. Jar The import order is incorrect. You should set Classes. Jar In the order Android. Jar Previously, specific adjustments Build class path order In Properties-> JAVA build path-> order and export. .


After successfully solving these two problems, I believe you can use them normally.AndroidHideAPI.

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.