How to use the hidden API in Android app development

Source: Internet
Author: User

The first point to note is thatGoogle is going to hide some APIs (the addition of @hide marked public class, method, or constant) for a reason. The big reason for this is that the Android system itself is in constant evolutionary development. From 1.0,1.1 to the now-coming Android 2.3.4. These hidden APIs themselves may be unstable, so using a hidden APImeans that the program is worse for compatibility.


     if you want me to give advice, it's best not to use hidden api . But sometimes in order to implement android apply some special features or effects, hidden api can often play an unexpected role. These api What can I do, I'm not here for example. Well, if you don't know how to hide


     don't want to go into the long-winded, straight to the chase. Use hidden api There are two main ways: I'm in java Learning of the reflection mechanism "the reflection method mentioned in the article gets hidden jar package generated when compiling with source code classes.jar .


     use reflection in a way that is not described here in detail, see" Span style= "FONT-SIZE:10.5PT; Color:rgb (0, 0, 255); Font-family: Song body; Text-decoration:underline; " >java Learning of the reflection mechanism ". Using the reflection mechanism to hide api , using reflection is no doubt annoying to programmers.


     This article is mainly about importing a fully compiled classes.jar Package for the use of hidden api in SDK becomes visible in the same way. Its disadvantage is the compatibility problem, I hope users pay attention to, in the use of a clear consideration.


     compile android Framework Source code, the source path will be generated under the out folder, In this folder out "target" common "obj" java_libraries "Framework_ Intermediates " Path, the compiled jar Library classes.jar . All you need to do is to import this


During the import Classes.jar process, there are two issues that may occur (I use the Eclipse development environment, so I will only explain the issues that this environment encounters).


The first problem is to import this jar Library by importing other jars , discovering that the compilation is slow and sometimes not even successful,Eclipse crashes or prompts " Java.lang.OutOfMemoryError:Java Heap Space"error. This problem may be due to the jar is too large for the reason, Online said change Eclipse.iniin the argument, the individual tried it, and seemed to have little effect. My approach is toeclipse new custom library , and then library the . android Project Add , just like using sdk . This can be a good solution to this problem. How to create a new custom library I do not detail, do not know the friends of their own search under or groping under, very simple.


     The second problem is that the jar Library was correctly imported, but found that the hidden api . The reason for this is build class path order not right, specifically. android.jar and is not imported in the correct order. You should place android.jar before the specific adjustment build class path order the place is in the properties -> java build path -> order  and export. .


After successfully solving these two problems, I believe you can use the Android hide API normally .


How to use the hidden API in Android app development

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.