는하지만 당신은 그것을 달성 할 수 지정된 수
에 안드로이드 응용 프로그램에서 부재중 전화를 걸 보장 (다른 사람이 즉시 전화를받을 경우)! 1 링 동안 얼마나 걸리는지 계산하십시오. Thread/Timer
을 시작한 다음이 메서드를 호출하여 호출을 끝내십시오!
private void mEndCall() {
try {
String serviceManagerName = "android.os.ServiceManager";
String serviceManagerNativeName = "android.os.ServiceManagerNative";
String telephonyName = "com.android.internal.telephony.ITelephony";
Class telephonyClass;
Class telephonyStubClass;
Class serviceManagerClass;
Class serviceManagerStubClass;
Class serviceManagerNativeClass;
Class serviceManagerNativeStubClass;
Method telephonyCall;
Method telephonyEndCall;
Method telephonyAnswerCall;
Method getDefault;
Method[] temps;
Constructor[] serviceManagerConstructor;
// Method getService;
Object telephonyObject;
Object serviceManagerObject;
telephonyClass = Class.forName(telephonyName);
telephonyStubClass = telephonyClass.getClasses()[0];
serviceManagerClass = Class.forName(serviceManagerName);
serviceManagerNativeClass = Class.forName(serviceManagerNativeName);
Method getService = // getDefaults[29];
serviceManagerClass.getMethod("getService", String.class);
Method tempInterfaceMethod = serviceManagerNativeClass.getMethod(
"asInterface", IBinder.class);
Binder tmpBinder = new Binder();
tmpBinder.attachInterface(null, "fake");
serviceManagerObject = tempInterfaceMethod.invoke(null, tmpBinder);
IBinder retbinder = (IBinder) getService.invoke(serviceManagerObject, "phone");
Method serviceMethod = telephonyStubClass.getMethod("asInterface", IBinder.class);
telephonyObject = serviceMethod.invoke(null, retbinder);
//telephonyCall = telephonyClass.getMethod("call", String.class);
telephonyEndCall = telephonyClass.getMethod("endCall");
//telephonyAnswerCall = telephonyClass.getMethod("answerRingingCall");
telephonyEndCall.invoke(telephonyObject);
} catch (Exception e) {
e.printStackTrace();
Log.e("error",
"FATAL ERROR: could not connect to telephony subsystem");
}
}
내가 전화를하면 뿌리를 제외 제어가없는 시스템에 의해 이루어지기 때문에 호출이 시작되기 전에, 당신은 끊을 수 있습니다 가능하다고 생각하지 않습니다
(http://stackoverflow.com/ 질문/599443/how-to-hang-up-outgoing-call-in-android). 그러나 통화 도중이 아닙니다. – WenChao