Android APIs
public abstract class

InCallService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.telecom.InCallService

Class Overview

This service is implemented by any app that wishes to provide the user-interface for managing phone calls. Telecom binds to this service while there exists a live (active or incoming) call, and uses it to notify the in-call app of any live and recently disconnected calls. An app must first be set as the default phone app (See getDefaultDialerPackage()) before the telecom service will bind to its InCallService implementation.

Below is an example manifest registration for an InCallService. The meta-data (METADATA_IN_CALL_SERVICE_UI) indicates that this particular InCallService implementation intends to replace the built-in in-call UI.

 <service android:name="your.package.YourInCallServiceImplementation"
          android:permission="android.permission.BIND_IN_CALL_SERVICE">
      <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
      <intent-filter>
          <action android:name="android.telecom.InCallService"/>
      </intent-filter>
 </service>
 
 

Summary

Nested Classes
class InCallService.VideoCall Used to issue commands to the Connection.VideoProvider associated with a Call
Constants
String SERVICE_INTERFACE The Intent that must be declared as handled by the service.
[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
InCallService()
Public Methods
final boolean canAddCall()
Returns if the device can support additional calls.
final CallAudioState getCallAudioState()
Obtains the current phone call audio state.
final List<Call> getCalls()
Obtains the current list of Calls to be displayed by this in-call service.
IBinder onBind(Intent intent)
Return the communication channel to the service.
void onBringToForeground(boolean showDialpad)
Called to bring the in-call screen to the foreground.
void onCallAdded(Call call)
Called when a Call has been added to this in-call session.
void onCallAudioStateChanged(CallAudioState audioState)
Called when the audio state changes.
void onCallRemoved(Call call)
Called when a Call has been removed from this in-call session.
void onCanAddCallChanged(boolean canAddCall)
Called when the ability to add more calls changes.
boolean onUnbind(Intent intent)
Called when all clients have disconnected from a particular interface published by the service.
final void setAudioRoute(int route)
Sets the audio route (speaker, bluetooth, etc...).
final void setMuted(boolean state)
Sets the microphone mute state.
[Expand]
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

public static final String SERVICE_INTERFACE

Added in API level 23

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

Constant Value: "android.telecom.InCallService"

Public Constructors

public InCallService ()

Added in API level 23

Public Methods

public final boolean canAddCall ()

Added in API level 23

Returns if the device can support additional calls.

Returns
  • Whether the phone supports adding more calls.

public final CallAudioState getCallAudioState ()

Added in API level 23

Obtains the current phone call audio state.

Returns
  • An object encapsulating the audio state. Returns null if the service is not fully initialized.

public final List<Call> getCalls ()

Added in API level 23

Obtains the current list of Calls to be displayed by this in-call service.

Returns
  • A list of the relevant Calls.

public IBinder onBind (Intent intent)

Added in API level 23

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 The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
  • Return an IBinder through which clients can call on to the service.

public void onBringToForeground (boolean showDialpad)

Added in API level 23

Called to bring the in-call screen to the foreground. The in-call experience should respond immediately by coming to the foreground to inform the user of the state of ongoing Calls.

Parameters
showDialpad If true, put up the dialpad when the screen is shown.

public void onCallAdded (Call call)

Added in API level 23

Called when a Call has been added to this in-call session. The in-call user experience should add necessary state listeners to the specified Call and immediately start to show the user information about the existence and nature of this Call. Subsequent invocations of getCalls() will include this Call.

Parameters
call A newly added Call.

public void onCallAudioStateChanged (CallAudioState audioState)

Added in API level 23

Called when the audio state changes.

Parameters
audioState The new CallAudioState.

public void onCallRemoved (Call call)

Added in API level 23

Called when a Call has been removed from this in-call session. The in-call user experience should remove any state listeners from the specified Call and immediately stop displaying any information about this Call. Subsequent invocations of getCalls() will no longer include this Call.

Parameters
call A newly removed Call.

public void onCanAddCallChanged (boolean canAddCall)

Added in API level 23

Called when the ability to add more calls changes. If the phone cannot support more calls then canAddCall is set to false. If it can, then it is set to true. This can be used to control the visibility of UI to add more calls.

Parameters
canAddCall Indicates whether an additional call can be added.

public boolean onUnbind (Intent intent)

Added in API level 23

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

Parameters
intent The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
  • Return true if you would like to have the service's onRebind(Intent) method later called when new clients bind to it.

public final void setAudioRoute (int route)

Added in API level 23

Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will be change to the getCallAudioState().

Parameters
route The audio route to use.

public final void setMuted (boolean state)

Added in API level 23

Sets the microphone mute state. When this request is honored, there will be change to the getCallAudioState().

Parameters
state true if the microphone should be muted; false otherwise.