CallRedirectionService
public
abstract
class
CallRedirectionService
extends Service
| java.lang.Object | ||||
| ↳ | 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 | |
|---|---|
String |
SERVICE_INTERFACE
The |
Inherited constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
android.app.Service
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.Context
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks2
|
Public constructors | |
|---|---|
CallRedirectionService()
|
|
Public methods | |
|---|---|
final
void
|
cancelCall()
The implemented |
final
IBinder
|
onBind(Intent intent)
Return the communication channel to the service. |
abstract
void
|
onPlaceCall(Uri handle, PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse)
Telecom calls this method once upon binding to a |
void
|
onPlaceCall(Uri handle, Uri originalHandle, PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse)
Telecom calls this method once upon binding to a |
void
|
onRedirectionTimeout()
Telecom calls this method when times out waiting for the |
final
boolean
|
onUnbind(Intent intent)
Called when all clients have disconnected from a particular interface published by the service. |
final
void
|
placeCallToAlternateNumber(Uri alternateUri, PhoneAccountHandle targetPhoneAccount, boolean confirmFirst)
The implemented |
final
void
|
placeCallUnmodified()
The implemented |
final
void
|
redirectCall(Uri gatewayUri, PhoneAccountHandle targetPhoneAccount, boolean confirmFirst)
The implemented |
Inherited methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
android.app.Service
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.ContextWrapper
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
android.content.Context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From class
java.lang.Object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From interface
android.content.ComponentCallbacks
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Constants
SERVICE_INTERFACE
public static final String SERVICE_INTERFACE
The Intent that must be declared as handled by the service.
Constant Value: "android.telecom.CallRedirectionService"
Public constructors
Public methods
cancelCall
public final void cancelCall ()
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
public final IBinder onBind (Intent intent)
Return the communication channel to the service. May return null if
clients can not bind to the service. The returned
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. |
| Returns | |
|---|---|
IBinder |
This value may be null. |
onPlaceCall
public abstract void onPlaceCall (Uri handle, PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse)
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. |
onPlaceCall
public void onPlaceCall (Uri handle, Uri originalHandle, PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse)
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.net.Uri, android.telecom.PhoneAccountHandle, boolean) once each time it binds to a
CallRedirectionService.
This method is same as onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) above,
but includes the original dial string.
| Parameters | |
|---|---|
handle |
Uri: the phone number dialed by the user, represented in E.164 format.
This value cannot be null. |
originalHandle |
Uri: the phone number dialed by the user in the original format it was
dialed (i.e. not E.164 format). This is helpful for numbers in some regions where
formatting to E.164 can cause the loss of suffix digits that the service needs to know
about.
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
public void onRedirectionTimeout ()
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
public final boolean onUnbind (Intent intent)
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. |
| Returns | |
|---|---|
boolean |
Return true if you would like to have the service's
onRebind(Intent) method later called when new clients bind to it. |
placeCallToAlternateNumber
public final void placeCallToAlternateNumber (Uri alternateUri, PhoneAccountHandle targetPhoneAccount, boolean confirmFirst)
The implemented CallRedirectionService calls this method to respond to a request
received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that
the call should be placed to a different number entirely.
This is in contrast to redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) which places
the call on the mobile network via a gateway number but still shows the original dialed
number to the user in the Dialer app. This method places the call to the specified number and
also shows that number to the user.
This is useful for apps which perform number rewriting to add dialing prefixes and the like.
Note: The targetPhoneAccount can only be used to place a call via a
PhoneAccount with PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION.
| Parameters | |
|---|---|
alternateUri |
Uri: the alternate number to place the call to and to show to the user.
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) |
placeCallUnmodified
public final void placeCallUnmodified ()
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
public final void redirectCall (Uri gatewayUri, PhoneAccountHandle targetPhoneAccount, boolean confirmFirst)
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.
Note: The targetPhoneAccount can only be used to place a call via a
PhoneAccount with PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION.
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) |