Java 在Android SDK中,当尝试使用Class.forName时,我得到一个ClassNotFoundException

Java 在Android SDK中,当尝试使用Class.forName时,我得到一个ClassNotFoundException,java,android,class,reflection,telephonymanager,Java,Android,Class,Reflection,Telephonymanager,我想这个问题以前可能有人问过,但我无法对答案添加任何评论,所以我再次问 当我使用以下代码时,Class.forName行出现错误 TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Class c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony");

我想这个问题以前可能有人问过,但我无法对答案添加任何评论,所以我再次问

当我使用以下代码时,Class.forName行出现错误

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
提前感谢您提供的任何建议

编辑

我试过使用我看到的提到的ITelephony.AIDL。。。这个文件应该叫做ITelephony.java吗

根据这里的注释,我将代码更改为以下内容:;我现在得到一个nosuchmethod异常

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Class c = tm.getClass();
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);

嗯,你为什么不使用tm.getClass来获取类?@commonware-当我这样做时,我会在下一行得到一个NoSuchMethodException。方法m=c.GetDeclaredMethodGettelePhony;还有,很抱歉没有尽快回复;我一直忙着工作,有一阵子没来这里查看。