我试图断开呼入来电,但面对这个错误如何终止内ITelephony
public interface ITelephony {
boolean endCall();
void answerRingingCall();
void silenceRinger();
}
private void disconnectPhoneItelephony(Context context)
{
ITelephony telephonyService;
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
try
{
telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.endCall();
}
catch (Exception e)
{
e.printStackTrace();
Log.d("error", e.toString());
}
}
错误:
(java.lang.ClassCastException:com.android.internal.telephony.ITelephony$Stub$
Proxy cannot be cast to belllab.com.meetingmanager.ITelephony)
检查导入的文件包名称和你的。 – RameshJaga
打包名称正确 – Hami
看看您是否在项目中添加了ITelephony.AIDL文件?如果你已经添加,那么你的包名必须包名称必须是COM /安卓/内部/电话/ ITelephony.AIDL – RameshJaga