找回密码
 注册

QQ登录

只需一步,快速开始

查看: 453|回复: 2

Interrupting a call

[复制链接]
发表于 2010-11-17 15:24:16 | 显示全部楼层 |阅读模式
As far as I know there is no public API for interrupting/ending a call. You can detect calls and the states of calls, maybe even prevent an outgoing call, but there is no API for ending an ongoing call.
This must be a security issue, but I also met the need of this feature, and only was able to do some workaround: turning on airplane mode interrupts all wireless connections including phone calls.The problem is that this method has side effects like, interrupting Internet connection, makes the phone  completely unavailable for incoming calls too and I'm not sure how does it affect emergency calls. The [color=blue ! important][color=blue ! important]phone [color=blue ! important]number can be checked so the emergency call issue can be solved anyway. My main problem was, that turning off the airplane mode requires PIN code, so even if we programmatically turn it on, and immediately off the airplane mode the user is forced to enter PIN code, and the device cannot even receive incoming calls.
So if anyone knows a better solution in the community please share with us.
Lets see some sample code for detecting an outgoing call and turning on airplane mode.
Detecting a call can be done with creating a Broatcastreciever, and registring it into the AndroidManifest like below:
  • public class CallReceiver extends BroadcastReceiver {
  •   @Override
  •   public void onReceive(Context arg0, Intent arg1) {
  •     //this method runs on new outgoing call
  •   }
  • }



  • <receiver android:name=".CallReceiver">
  •   <intent-filter>
  •     <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
  •   </intent-filter>
  • </receiver>



The airplane can be turned on like this:
  • android.provider.Settings.System.putInt(context.getContentResolver(android.provider.Settings.System.AIRPLANE_MODE_ON, 1);
  • Intent airplaneIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
  • airplaneIntent.putExtra("state", 1);
  • context.sendBroadcast(new Intent("android.intent.action.AIRPLANE_MODE"));
  • context.sendBroadcast(airplaneIntent);



You can combine the two, start an alarmaManager and turn the airplane mode on, and after a given amount of time interrupt the call.

http://www.helloandroid.com/tutorials/interrupting-call

发表于 2011-5-27 03:07:17 | 显示全部楼层
楼主的好帖  严重支持!!!

欢迎论坛里多多这样的帖子!!




快速丰胸,产后如何丰胸,如何健康丰胸
发表于 2011-6-7 22:42:17 | 显示全部楼层
楼主的这个帖子不错哈

千年遇好帖,遇到必须顶

顶一下看看


Millasha,Millasha,Millasha,Millasha官网地址,Millasha
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-5-28 15:43 , Processed in 0.016200 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表