Share via


TelecomManager.AddCall Method

Definition

Add a call to the Android system service 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

Parameters

callAttributes
CallAttributes

attributes of the new call (incoming or outgoing, address, etc.)

executor
IExecutor

execution context to run CallControlCallback updates on

pendingControl
IOutcomeReceiver

Receives the result of addCall transaction. Upon success, a CallControl object is provided which can be used to do things like disconnect the call that was added.

handshakes
ICallControlCallback

callback that receives <b>actionable</b> updates that originate from Telecom.

events
ICallEventCallback

callback that receives <b>non</b>-actionable updates that originate from Telecom.

Attributes

Remarks

Add a call to the Android system service Telecom. This allows the system to start tracking an incoming or outgoing call with the specified CallAttributes. Once the call is ready to be disconnected, use the CallControl#disconnect(DisconnectCause, Executor, OutcomeReceiver) which is provided by the pendingControl#onResult(CallControl).

<b>Call Lifecycle</b>: Your app is given foreground execution priority as long as you have a valid call and are posting a android.app.Notification.CallStyle notification. When your application is given foreground execution priority, your app is treated as a foreground service. Foreground execution priority will prevent the android.app.ActivityManager from killing your application when it is placed the background. Foreground execution priority is removed from your app when all of your app's calls terminate or your app no longer posts a valid notification.

<b>Note</b>: Only packages that register with PhoneAccount#CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS can utilize this API. PhoneAccounts that set the capabilities PhoneAccount#CAPABILITY_SIM_SUBSCRIPTION, PhoneAccount#CAPABILITY_CALL_PROVIDER, PhoneAccount#CAPABILITY_CONNECTION_MANAGER are not supported and will cause an exception to be thrown.

<b>Usage example:</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);

Java documentation for 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).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to