如何在 ITelephony 中终止来电
How to terminate an incoming call within 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 )
我正在尝试断开来电但遇到此错误
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 )