Run*_*ion 24 android telephony telephonymanager
这是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 /
http://www.emoticode.net/android-sdk/block-incoming-and-outgoing-phone-calls-programmatically.html
如何在Android应用程序开发中阻止手机号码呼叫和消息接收?
和http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html
还有更多问题,答案和建议......
所有人都说ITelephonyService.aidl与TelephonyManager结合使用
并且该解决方案在许多设备上都运行良好,但它不适用于Samsung S Duos.我挣扎了一个星期,但没有得到解决方案..是否有任何特殊的API可以在这种类型的设备上工作?我如何拒绝来电?请帮我...
Jeb*_*han 66
试试这个肯定会起作用.它对我来说很好.
您可以从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);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21390 次 |
| 最近记录: |