Android Studio View Android internal hidden source code
problem finding
When I checked the source code of AlertDialog today, I saw AlertController, and found that all the codes about this part are red. It turns out that the AlertController class is under the package com.android.internal.app, look at the package name internal (internal), which means this Part of the code is not open to the public due to factors such as security and stability of Google.
problem solving
In fact, this problem has always existed, but I didn't check these hidden source codes carefully before, and I just passed by! Then there is a problem, it must be solved, how to solve this? In fact, there are still solutions:
the first solution:
http://androidxref.com/ The source code of each version of Android (including the C layer) is available under this URL, which are all online and easy to view:
Feel free to click on a version and go, we enter the class we want to find:
We find this class, click it to view the source code of this class, which is more convenient.
The second solution:
GitHub has removed the @hide annotation in Android.jar, the source code here is relatively complete (note that it can only be relatively complete, there is still no code for the C layer, because it is only a jar package)
Address: https ://github.com/anggrayudi/android-hidden-api
- Close Android Studio
- Download the Android.jar corresponding to the API version
- Replace SDK/platforms/android-versions/Android.jar
- Reopen Android Stuido to view
At this time, we can view these hidden APIs at will in Android Studio.
Summarize
Both methods are actually possible, and both methods have their own advantages and disadvantages. The first method is simple, including the C-layer source code, but it is not very convenient to view the code and jump; the second method is more suitable for viewing the Java source code, and the jump is convenient, but there is no C-layer source code. Generally, when I use it, I use the two together, and the efficiency will be better!
Friends of Jane who like this blog, please come to a wave of likes. Every time you pay attention, it will become the driving force for me to move forward. Thank you!