Use internal (COM. Android. Internal) and hidden (@ hide) APIs-Part 3

Source: Internet
Author: User

Xirihanlin 2011.06.03

Original path: http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-3-custom-android-platform/

In my previous article, I have demonstrated how to create a original-android.jar that contains all the internal and hidden APIs.

The next step is to modify the existing Android platform (sdk_dir/platforms/platform-x/Android. jar, X indicates the API level ). You can replace Android. Jar directly with the original-android.jar created in Part2. However, in this case, all your projects will directly use the internal and hidden APIs without any restrictions. This is not convenient, because you do not want this in most projects. You may even want to disable these APIs (default behavior of ADT/Android. Jar ). But for some specific projects, you want to use these internal and hidden APIs.

To achieve this flexibility, you need to create a new custom Android platform. When you do not need to access internal and hidden APIs, you only need to use the original Android platform. When you use these APIs, you use a custom Android platform.

Android SDKFolder structure

Let's take a look at how the android SDK tree is organized:

We need the "platforms" folder. Let's take a look:

The supported Android platforms are listed here.

Now, let's take a look at how it is associated with eclipse settings. Right-click your project and choose Properties> android. You will see a group of supported Android platforms... /Platforms/folder is similar ). Below is:

Create a new platform

To create a new platform, we need to copy the Android-9 folder> Android-9-internals. Let's make some corrections:

1. Delete Android. Jar

2. Copy the original-android.jar and rename it Android. Jar

3. Modify the build. Prop file:

...

Ro. Build. version. SDK = 9-> Ro. Build. version. SDK =-9

...

Ro. Build. version. Release = 2.3-> Ro. Build. version. Release = 2.3.extended

...

Restart eclipse. Confirm that you can see the new platform. Below is what I see:

Why do I select the API level-9? This is because it must be a number and cannot be 9 (or other existing API levels ). Otherwise, your custom platform cannot be used (it is visible in the list, but it cannot work normally after selection, and the original platform of the corresponding API level is still used during compilation ).

The following is a reference to the class library (the custom platform is selected for the current project ):

Summary

In the previous article, I have told you how to create an uncut version of Android. jar. In this article, I show you how to create a custom Android platform and use original-android.jar in it. This is sufficient for the hidden API. However, for internal APIs, another step is required. This is because the ADT still does not allow the class in the com. Android. Internal Package (see "forbidden" access rules in ). In the next section, I will show you how to customize the ADT to allow classes in the internal package.

============== Gorgeous split line ====================

In the actual operation process, the custom android. jar (API 10) cannot be successfully loaded by eclipse. the following error box is displayed, just like the results of other operations on the website. We look forward to the solution.

However, the author provides a custom Android. Jar available. If you do not want to try it yourself, you can download it directly from the website. The address will be provided in part5. please wait.

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.