private void endCall() {

Class<TelephonyManager> c = TelephonyManager.class;
Method getITelephonyMethod = null;
try {

getITelephonyMethod = c.getDeclaredMethod("getITelephony",(Class[]) null);

getITelephonyMethod.setAccessible(true);
ITelephony iTelephony = (ITelephony) getITelephonyMethod.invoke(mTelephonyManager, (Object[]) null);
iTelephony.endCall();
//iTelephony.dial("10086");
Log.v(this.getClass().getName(), "endCall......");
} catch (Exception e) {
Log.e(this.getClass().getName(), "endCallError", e);

}
这个方法,看不太懂,谁能帮我讲解一下?
谢谢

解决方案 »

  1.   

    这是一个java反射的场景,
    首先获得在Application Framework中获取一个TelephonyManager的实例 c
    然后之后的代码和android没什么关系了,就是java反射嘛 c.getDeclaredMethod 获取这个类声明了哪些方法,
    详见JDK API  这个包: java.lang.reflect
      

  2.   

    Class<TelephonyManager> c = TelephonyManager.class;
    Method getITelephonyMethod = null;
    try {getITelephonyMethod = c.getDeclaredMethod("getITelephony",(Class[]) null);getITelephonyMethod.setAccessible(true);这四句不懂,不了解反射?