编程结束来电 [英] end incoming call programmatically

查看:228
本文介绍了编程结束来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

拒绝在安卓来电

<一个href="http://stackoverflow.com/questions/15481524/how-to-programatically-answer-end-a-call-in-android-4-1">How以编程方式接听/结束通话Android中4.1?

<一个href="http://www.emoti$c$c.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html">http://www.emoti$c$c.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html

如何阻止Android的电话

<一个href="http://stackoverflow.com/questions/9904426/how-to-block-a-mobile-number-call-and-message-receiving-in-android-application-d/9904826#9904826">how阻止手机号码的呼叫和消息接收android应用开发?

和<一href="http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html">http://androidsource$c$c.blogspot.in/2010/10/blocking-incoming-call-android.html

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

and lot more questions, answers and suggestions...

所有的组合都在说使用 ITelephonyService.aidl 与<一个href="http://developer.android.com/reference/android/telephony/TelephonyManager.html">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文件href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/1.5_r4/com/android/internal/telephony/ITelephony.java">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); 
 }
}

这篇关于编程结束来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆