Using internal (com.android.internal) and hidden (@hide) APIs [Part 5, summary and example]
In order to enable usage of Internal and Hidden APIs without reflection you need:
- Create custom original-android.jar that includes all required .class files (details here)
- Create custom android platform that uses original-android.jar (details here).
- Modify ADT to allow usage of com.android.internal package (only for Internal API, details here).
- Create project that references custom android platform (example in this post)
In this post I’ll show how to actually use those Internal and Hidden APIs.
And as a bonus there is a list of already prepared custom android platforms with Internal and Hidden APIs enabled at the end of the post. I added them just in case you don’t have too much free time but want to try something out quickly.
Create new project, select 2.3.extended platform:
And here is code:
(you can copy actual code from here)
This code shows an example of Internal API usage (PowerProfile) and Hidden API usage (isWifiApEnabled). I can compile and run this code without using reflection.
Here is a bunch of platforms that I created for myself. Just copy them over to your SDK_DIR\platforms directory. This will enable Hidden API instantly. You’ll need to customize your ADT (see this post) to additionally enable Internal API.
Sorry, megaupload is currently down (and most likely will never be recovered). So the above links are not valid anymore.
But luckily I also have uploaded platforms 7, 8, 10 and 15 to github.