Added in API level 29

CallRedirectionService

abstract class CallRedirectionService : Service
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.app.Service
   ↳ android.telecom.CallRedirectionService

This service can be implemented to interact between Telecom and its implementor for making outgoing call with optional redirection/cancellation purposes.

Below is an example manifest registration for a CallRedirectionService. <service android:name="your.package.YourCallRedirectionServiceImplementation" android:permission="android.permission.BIND_CALL_REDIRECTION_SERVICE"> <intent-filter> <action android:name="android.telecom.CallRedirectionService"/> </intent-filter> </service>

Summary

Constants
static String

The Intent that must be declared as handled by the service.

Inherited constants
Public constructors

Public methods
Unit

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that an outgoing call should be canceled entirely.

IBinder?
onBind(intent: Intent)

Return the communication channel to the service.

abstract Unit
onPlaceCall(handle: Uri, initialPhoneAccount: PhoneAccountHandle, allowInteractiveResponse: Boolean)

Telecom calls this method once upon binding to a CallRedirectionService to inform it of a new outgoing call which is being placed.

open Unit

Telecom calls this method when times out waiting for the CallRedirectionService to call placeCallUnmodified(), redirectCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean), or cancelCall()

Boolean
onUnbind(intent: Intent)

Called when all clients have disconnected from a particular interface published by the service.

Unit

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that no changes are required to the outgoing call, and that the call should be placed as-is.

Unit
redirectCall(gatewayUri: Uri, targetPhoneAccount: PhoneAccountHandle, confirmFirst: Boolean)

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that changes are required to the phone number or/and PhoneAccountHandle for the outgoing call.

Inherited functions

Constants

SERVICE_INTERFACE

Added in API level 29
static val SERVICE_INTERFACE: String

The Intent that must be declared as handled by the service.

Value: "android.telecom.CallRedirectionService"

Public constructors

CallRedirectionService

CallRedirectionService()

Public methods

cancelCall

Added in API level 29
fun cancelCall(): Unit

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that an outgoing call should be canceled entirely.

This can only be called from implemented onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean).

onBind

Added in API level 29
fun onBind(intent: Intent): IBinder?

Return the communication channel to the service. May return null if clients can not bind to the service. The returned android.os.IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: This value cannot be null.
Return
IBinder? This value may be null.

onPlaceCall

Added in API level 29
abstract fun onPlaceCall(
    handle: Uri,
    initialPhoneAccount: PhoneAccountHandle,
    allowInteractiveResponse: Boolean
): Unit

Telecom calls this method once upon binding to a CallRedirectionService to inform it of a new outgoing call which is being placed. Telecom does not request to redirect emergency calls and does not request to redirect calls with gateway information.

Telecom will cancel the call if Telecom does not receive a response in 5 seconds from the implemented CallRedirectionService set by users.

The implemented CallRedirectionService can call placeCallUnmodified(), redirectCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean), and cancelCall() only from here. Calls to these methods are assumed by the Telecom framework to be the response for the phone call for which onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) was invoked by Telecom. The Telecom framework will only invoke onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) once each time it binds to a CallRedirectionService.

Parameters
handle Uri: the phone number dialed by the user, represented in E.164 format if possible This value cannot be null.
initialPhoneAccount PhoneAccountHandle: the PhoneAccountHandle on which the call will be placed. This value cannot be null.
allowInteractiveResponse Boolean: a boolean to tell if the implemented CallRedirectionService should allow interactive responses with users. Will be false if, for example the device is in car mode and the user would not be able to interact with their device.

onRedirectionTimeout

Added in API level 33
open fun onRedirectionTimeout(): Unit

Telecom calls this method when times out waiting for the CallRedirectionService to call placeCallUnmodified(), redirectCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean), or cancelCall()

onUnbind

Added in API level 29
fun onUnbind(intent: Intent): Boolean

Called when all clients have disconnected from a particular interface published by the service. The default implementation does nothing and returns false.

Parameters
intent Intent: This value cannot be null.
Return
Boolean Return true if you would like to have the service's onRebind method later called when new clients bind to it.

placeCallUnmodified

Added in API level 29
fun placeCallUnmodified(): Unit

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that no changes are required to the outgoing call, and that the call should be placed as-is.

This can only be called from implemented onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean).

redirectCall

Added in API level 29
fun redirectCall(
    gatewayUri: Uri,
    targetPhoneAccount: PhoneAccountHandle,
    confirmFirst: Boolean
): Unit

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean) to inform Telecom that changes are required to the phone number or/and PhoneAccountHandle for the outgoing call. Telecom will cancel the call if the implemented CallRedirectionService replies Telecom a handle for an emergency number.

This can only be called from implemented onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean).

Parameters
gatewayUri Uri: the gateway uri for call redirection. This value cannot be null.
targetPhoneAccount PhoneAccountHandle: the PhoneAccountHandle to use when placing the call. This value cannot be null.
confirmFirst Boolean: Telecom will ask users to confirm the redirection via a yes/no dialog if the confirmFirst is true, and if the redirection request of this response was sent with a true flag of allowInteractiveResponse via onPlaceCall(android.net.Uri,android.telecom.PhoneAccountHandle,boolean)