Android(AIDL)自动重复拨号及挂断/接听电话

 

Android默认没有提供挂断/接听电话的api,需要伪装com/android/internal/telephony/ITelephony.aidl的接口来欺骗系统。而自动重复拨号可以通过(BroadcastReceiver)监听电话状态(android.intent.action.PHONE_STATE)来实现。

 

<strong>1、Android挂断和接听电话的接口</strong>

<code lang='java' width='auto' height='auto'>

public static void endCall(Context cx) { //挂断电话

TelephonyManager telMag = (TelephonyManager) cx

.getSystemService(Context.TELEPHONY_SERVICE);

Class<TelephonyManager> c = TelephonyManager.class;

Method mthEndCall = null;

try {

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

mthEndCall.setAccessible(true);

ITelephony iTel = (ITelephony) mthEndCall.invoke(telMag,

(Object[]) null);

iTel.endCall();

} catch (Exception e) {

e.printStackTrace();

}

}

 

原文:Android(AIDL)自动重复拨号及挂断/接听电话 | http://orgcent.com/android-aidl-call-end-phone/


你可能感兴趣的:(android,aidl)