开发者

Non-public android classes

Hi to all android devlopers. Please, help me out from this:

1)How do i use non public classes in android like telephony, android.telephony.CallManager in my android application?

2) How do I import this telephony packa开发者_JS百科ges in my activity class and make it allow to access its functionality?


You can't and you shouldn't. These internal classes/APIs can change at any time without warning during an Android upgrade. there's no guarantee that they're implemented in the exact same way across different vendors.

Such changes can cause your application to break.

You should only use the public classes included in the android.jar


Reflection?

ClassLoader classLoader = TestActivity.class.getClassLoader();
final ClassLoader classLoader = this.getClass().getClassLoader();
try {
    final Class<?> classCallManager =
        classLoader.loadClass("com.android.internal.telephony.CallManager");
} catch (final ClassNotFoundException e) {
    Log.e("TestActivity", e);
}

And add

READ_PHONE_STATE

to your Manifest.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜