语言

TelecomManager.AddCall 方法

定义

添加对 Android 系统服务电信的调用。

[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

接收源自 Telecom 的可操作 更新的回调。

events
ICallEventCallback

接收 <来自 Telecom 的 b>个不可<操作>更新的回调。

特性

注解

添加对 Android 系统服务电信的调用。 这样,系统就可以开始使用指定的 CallAttributes传入或传出呼叫跟踪。 添加呼叫后,应发布通知,当呼叫准备好断开连接时,请使用由 <a0/&a0> 提供的通知。

调用生命周期:只要有有效的调用并发布 android.app.Notification.CallStyle 通知,应用就获得前台执行优先级。 当应用程序获得前台执行优先级时,应用将被视为前台服务。 前台执行优先级将阻止 android.app.ActivityManager 应用程序在放置后台时终止应用程序。 当应用的所有调用终止或应用不再发布有效的通知时,将从应用中删除前台执行优先级。

注意:只有注册到 PhoneAccount#CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS 的包才能使用此 API。 PhoneAccount设置功能PhoneAccount#CAPABILITY_SIM_SUBSCRIPTIONPhoneAccount#CAPABILITY_CALL_PROVIDER,不支持,PhoneAccount#CAPABILITY_CONNECTION_MANAGER并将导致引发异常。

用法示例:

// 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);

Java文档android.telecom.TelecomManager.addCall(android.telecom.CallAttributes, java.util.concurrent.Executor, android.os.OutcomeReceiver<android.telecom.CallControl, android.telecom.CallException>, android.telecom.CallControlCallback, android.telecom.CallEventCallback)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于