I got the idea from ryan gordon
Basically, anything marked with @hide
is removed when compiling the framework, which Android Studio uses to compile your code. You can fine that in \AppData\Local\Android\Sdk\platforms\android-xx\android.jar
. What ryan proposed, was to either compile android framework yourself without the @hide
, or to take an already compiled framework from a rooted phone (because @hide
doesn't affect code used in actual phones)
An simpler alternative in my opinion is to simply extract the .class
file from android.jar
, use any Java bytecode editor, and just add the missing method. Then replace the file in android.jar
.
However, just as Tamas Rev mentioned, methods marked with @hide
were never meant to be accessed, therefore there's no guarantee that it existed in older versions, or that the behavior is consistent across versions, or that it will exist in the future!