这是 SO 中一个熟悉的问题。我需要的是 以编程方式结束通话。 我已经搜索了很多...
http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html http://androiddesk.wordpress.com/2012/08/02/blocking-a-call-without-user-intervention-in-android/
Rejecting Incoming call in android
How to programmatically answer/end a call in Android 4.1?
http://www.emoticode.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html
how to block a mobile number call and message receiving in android application development?
和http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html
还有更多问题、答案和建议...
所有人都在说将 ITelephonyService.aidl
与 TelephonyManager 结合使用
该解决方案在许多设备上都能完美运行,但在 Samsung S Duos 上却无法运行。我挣扎了一个多星期,但没有得到解决方案.. 在这种类型的设备上是否有任何特殊的 API 可以使用?如何拒接来电?请帮帮我...
最佳答案
试试这个 肯定会奏效的。它对我来说很好。
您可以从 ITelephony.java 下载 ITelephony.java 文件
然后添加结束调用的方法:
断开调用的功能
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);
}
}
关于android - 以编程方式结束来电,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20965702/