Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用默认拨号程序应用取消拨出电话_Android_Android Bluetooth - Fatal编程技术网

Android 使用默认拨号程序应用取消拨出电话

Android 使用默认拨号程序应用取消拨出电话,android,android-bluetooth,Android,Android Bluetooth,我有一个成为默认拨号程序的应用程序 通过使用android.telecom类,它可以很好地处理来电、接听和挂断 现在我要做的是,当蓝牙手机拨打一个号码时,停止该拨号,并用该号码启动whatsapp拨号uri 您知道如何取消通过手机拨打的电话吗?您可以使用TelecomManager类来切断通话 TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);

我有一个成为默认拨号程序的应用程序

通过使用android.telecom类,它可以很好地处理来电、接听和挂断

现在我要做的是,当蓝牙手机拨打一个号码时,停止该拨号,并用该号码启动whatsapp拨号uri


您知道如何取消通过手机拨打的电话吗?

您可以使用
TelecomManager
类来切断通话

TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);

if (telecomManager != null) {
if(telecomManager .endCall())
Toast(mContext,"Call ended",Toast.LENGTH_SHORT).show();
else
Toast(mContext,"Failed to end the call",Toast.LENGTH_SHORT).show();
}
你需要许可

<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
 <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 
更新清单

<receiver  android:name=".OutGoingCallReceiver" 
android:exported="true"> 
<intent-filter>   
<action
android:name="android.intent.action.NEW_OUTGOING_CALL"
android:priority="0" /> 
</intent-filter> 
</receiver>


您需要使用广播接收器来获取该事件,以及如何在收到该事件后取消呼叫。但是,我需要切断来自蓝牙扬声器的传出呼叫,并将其重定向到whatsapp。这会监听传出的电话吗?啊,好的,我会尝试你的解决方案并报告。谢谢您,您的解决方案在sdk 26+上非常有效,但我客户的电话是23,我需要使用不同的解决方案,而不是接听电话。你有什么快速提示吗?这里有一个ITelephony类,因为这个答案非常好,我将为android 6.0.1添加另一个问题
<receiver  android:name=".OutGoingCallReceiver" 
android:exported="true"> 
<intent-filter>   
<action
android:name="android.intent.action.NEW_OUTGOING_CALL"
android:priority="0" /> 
</intent-filter> 
</receiver>