编程结束来电结束

2023-09-12 04:13:21 作者:清风挽心

这是这么熟悉的问题。而我需要的是 结束通话编程。 我搜索了很多......

This is a familiar question in SO. and what I need is to end call programmatically. I have searched a lot...

http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html http://androiddesk.word$p$pss.com/2012/08/02/blocking-a-call-without-user-intervention-in-android/

拒绝在安卓来电

How以编程方式接听/结束通话Android中4.1?

http://www.emoti$c$c.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html

如何阻止Android的电话

how阻止手机号码的呼叫和消息接收android应用开发?

和http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html

和很多的问题,答案和建议...

and lot more questions, answers and suggestions...

所有的组合都在说使用 ITelephonyService.aidl 与TelephonyManager

All are saying use ITelephonyService.aidl in combination with TelephonyManager

和解决方案正在完善在许多设备上,但它不工作在三星小号二重奏。我挣扎了一个多星期,但没有得到解决.. 有没有什么特殊的API来对这类设备的工作呢?我该如何拒绝来电?请帮我...

and the solution is working perfect on many devices but it's not working on Samsung S Duos. I am struggling over a week but didn't get a solution.. is there any special API to work with on this type of devices? How can I reject incoming call? please help me...

推荐答案

试试这个肯定它会工作。它的工作对我罚款。

Try this Sure it will work. It's working fine for me.

您可以下载从ITelephony.java

在您添加到结束通话的方式:

After that you add the method to end call:

public void disconnectCall(){
 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<?> serviceManagerNativeClass;
    Method telephonyEndCall;
    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);
    telephonyEndCall = telephonyClass.getMethod("endCall");
    telephonyEndCall.invoke(telephonyObject);

  } catch (Exception e) {
    e.printStackTrace();
    Log.error(DialerActivity.this,
            "FATAL ERROR: could not connect to telephony subsystem");
    Log.error(DialerActivity.this, "Exception object: " + e); 
 }
}