shiv1229
shiv1229

Reputation: 357

how to use android Internal API's

Can anyone tell me, how to import Android hidden/internal API's into my application?

For example, com.android.internal.telephony. How to import this APi into application? Thanks in advance.

Upvotes: 1

Views: 1033

Answers (1)

Sean Owen
Sean Owen

Reputation: 66886

If the classes are available at runtime, but not compile time, yes you can't compile against them directly in your code but you can still try to load them via reflection. We used this in Android 1.x to load a hidden internal class that controlled the LED light on some devices. It is difficult since every method call turns into several lines of calls to java.lang.reflect classes. See here:

http://www.google.com/codesearch#k59QJW14udA/android/src/com/google/zxing/client/android/camera/FlashlightManager.java

Of course, these APIs or classes would not at all be guaranteed to be present on all devices, and could change or disappear, so this is brittle. And it may be that there's a SecurityManager protecting access to certain internals too, I don't know.

Upvotes: 2

Related Questions