TelecomManager.AddCall 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
新增一通電話給 Android 系統服務 Telecom。
[Android.Runtime.Register("addCall", "(Landroid/telecom/CallAttributes;Ljava/util/concurrent/Executor;Landroid/os/OutcomeReceiver;Landroid/telecom/CallControlCallback;Landroid/telecom/CallEventCallback;)V", "GetAddCall_Landroid_telecom_CallAttributes_Ljava_util_concurrent_Executor_Landroid_os_OutcomeReceiver_Landroid_telecom_CallControlCallback_Landroid_telecom_CallEventCallback_Handler", ApiSince=34)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_OWN_CALLS")]
public virtual void AddCall(Android.Telecom.CallAttributes callAttributes, Java.Util.Concurrent.IExecutor executor, Android.OS.IOutcomeReceiver pendingControl, Android.Telecom.ICallControlCallback handshakes, Android.Telecom.ICallEventCallback events);
[<Android.Runtime.Register("addCall", "(Landroid/telecom/CallAttributes;Ljava/util/concurrent/Executor;Landroid/os/OutcomeReceiver;Landroid/telecom/CallControlCallback;Landroid/telecom/CallEventCallback;)V", "GetAddCall_Landroid_telecom_CallAttributes_Ljava_util_concurrent_Executor_Landroid_os_OutcomeReceiver_Landroid_telecom_CallControlCallback_Landroid_telecom_CallEventCallback_Handler", ApiSince=34)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_OWN_CALLS")>]
abstract member AddCall : Android.Telecom.CallAttributes * Java.Util.Concurrent.IExecutor * Android.OS.IOutcomeReceiver * Android.Telecom.ICallControlCallback * Android.Telecom.ICallEventCallback -> unit
override this.AddCall : Android.Telecom.CallAttributes * Java.Util.Concurrent.IExecutor * Android.OS.IOutcomeReceiver * Android.Telecom.ICallControlCallback * Android.Telecom.ICallEventCallback -> unit
參數
- callAttributes
- CallAttributes
新通話的屬性(來電或去電、地址等)
- executor
- IExecutor
執行上下文以執行 CallControlCallback 更新
- pendingControl
- IOutcomeReceiver
接收 addCall 交易的結果。 成功後,會提供一個 CallControl 物件,可用於斷開新增通話等操作。
- handshakes
- ICallControlCallback
回撥接收 <來自電信的 B>可操作</B> 更新。
- events
- ICallEventCallback
回撥接收<來自電信的 B>個非<>可操作更新。
- 屬性
備註
新增一通電話給 Android 系統服務 Telecom。 這讓系統能開始追蹤指定的 CallAttributes來電或出電。 通話加入後,android.app.Notification.CallStyle應發布通知,當通話準備掛斷時,請使用CallControl#disconnect(DisconnectCause, Executor, OutcomeReceiver)pendingControl#onResult(CallControl)由 .
<b>呼叫生命週期</b>:只要你有有效呼叫並發布 android.app.Notification.CallStyle 通知,應用程式就會獲得前景執行優先權。 當你的應用程式獲得前台執行優先權時,你的應用程式會被視為前台服務。 前景執行優先權會防止應用程式 android.app.ActivityManager 在放置背景時被終止。 當應用程式的所有通話終止或應用程式不再發布有效通知時,前景執行優先權將從應用程式中移除。
<b>注意/b<:只有註冊的>套件PhoneAccount#CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS才能使用此 API。
PhoneAccount設定能力 PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION、 PhoneAccount#CAPABILITY_CALL_PROVIDER、 的 PhoneAccount#CAPABILITY_CONNECTION_MANAGER s 不被支援,會導致拋出例外。
<b>使用範例:</b>
// Its up to your app on how you want to wrap the objects. One such implementation can be:
class MyVoipCall {
...
public CallControlCallEventCallback handshakes = new CallControlCallback() {
...
}
public CallEventCallback events = new CallEventCallback() {
...
}
public MyVoipCall(String id){
...
}
}
MyVoipCall myFirstOutgoingCall = new MyVoipCall("1");
telecomManager.addCall(callAttributes,
Runnable::run,
new OutcomeReceiver() {
public void onResult(CallControl callControl) {
// The call has been added successfully. For demonstration
// purposes, the call is disconnected immediately ...
callControl.disconnect(
new DisconnectCause(DisconnectCause.LOCAL) )
}
},
myFirstOutgoingCall.handshakes,
myFirstOutgoingCall.events);
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。