如何在android dev中取消去电? [英] How to cancel outgoing call in android dev.?
本文介绍了如何在android dev中取消去电?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想知道是否要在android dev中取消去电?
I just want to know if how to cancel outgoing call in android dev.? Is it possible in the simplest way of coding?
推荐答案
您需要创建一个 BroadCastReceiver
将在操作中调用: NEW_OUTGOING_CALL
You need to create a BroadCastReceiver
that will be called on the action : NEW_OUTGOING_CALL
Java类:
public class CallReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)){
setResultData(null);
abortBroadcast(); // cancel the call
}
}
}
清单声明
编辑
不要忘记添加运行许可
Edit don't forget add out going permission
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<receiver android:name=".CallReceiver" >
<intent-filter android:priority="2147483647" >
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
使用此代码,所有通话将被取消,并且在这种情况下您将无法进行通话该应用已在您的手机上
With this code, any call will be canceled and you will not be able to do a call if this app is on your phone
这篇关于如何在android dev中取消去电?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文