我試圖斷開呼入來電,但面對這個錯誤如何終止內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