Posted by Luke Hopkins – Developer Relations Engineer
Today we’re thrilled to announce that the Telecom jetpack library is now in alpha for developers who already have or are interested in creating voice and/or video calling applications. Our aim with this library is to simplify the developer integration process and improve VoIP calling across Android surfaces.
androidx.core:core-telecom:1.0.0-alpha02
What’s in the Public Alpha release
This release supports a variety of Telecom features, including:
Platform synchronization
For surfaces like watches, this library allows the user to answer, decline, hang up and mute your call through a simple API, as well as displaying useful information such as who the caller is.
This is also beneficial because if the device is aware of your call, should other calls such a PTSN/SIM based call come through, you can give the user a chance to hold the call they are currently on.
Dedicated foreground support
With the changes to Android 14, which require applications to specify foreground service types, this library takes care of the requirements for you. For more information, please refer to the foreground service documentation.
Foreground support allows users to stay connected to their calls even after the user has navigated away from your app… You won’t need to build your own foreground services or worry about the background state of your application.
Audio Routing
Instead of using the audio manager to track state, focus and obtain a list of audio devices, this Telecom library will list all available endpoints to your application for streaming audio to/from Bluetooth hearables, hearing aids, wired headphones, and other surfaces, thus giving users access and control to a wide range of hearable devices.
Backwards Compatibility
Backwards compatibility works all the way down to Android O (API Level 26) on devices which support the Telecom stack which means implementing the simple API surface below supports a wide range of devices.
callsManager.addCall(
attributes,
onIsCallAnswered,
onIsCallDisconnected,
onIsCallActive,
onIsCallInactive
){
val callScope=this
}
You can also query the packagemanager to know if the device supports Telecom.
packagemanager.hasSystemFeature(PackageManager.FEATURE_TELECOM)
Why use this library over Platform API
You might be thinking, why make this move to a new library when I could just similarly migrate the deprecated APIs to the new APIs added in Android 14. Well this library offers:
New Features
We will have more exciting additions coming to the Telecom library in the coming months which are exclusive to the jetpack library. These included expanded support for VoIP Call actions such as being able to locally mute the VoIP app for the specific call and being able to display the name of the speaker on another surface such as Android Auto. We also have a new feature coming soon that will allow users to transfer their ongoing VoIP calls between their phones and tablets.
Backward Compatibility
As previously stated, this library supports backward compatibility, which means that your app will not only be supported on a wider range of devices, but we can resolve interoperability issues with older Android versions.
A simple API surface and a large coverage of devices, means this library is the goto solution for calling applications.
Migrating from ConnectionService to CallsManager
Even if you already have an existing ConnectionService integration for your VoIP app, you should consider migrating to CallsManager, as mentioned above we have a lot of exciting features coming to this library and using the jetpack library will give you a simple and complete solution moving forward.
Migrating from ConnectionService to CallManager is fairly straightforward to implement but is not a simple case of changing namespace. You can think of CallManager representing ConnectionService and CallControlScope representing ConnectionService.
Below shows the difference between how to switch audio using connection service to CallControlScope.
You can also query the packagemanager to know if the device supports Telecom.
cconnectionService.setAudioRoute (int route)
when (requestEndpointChange(newEndpoint)) {
is CallControlResult.Success -> {
// Device changed
}
is CallControlResult.Error -> {
}
}
Another example showing how simple this API is to use, you can add a call to the platform and define you call attributes with the code below:
val attributes = CallAttributesCompat(
displayName = displayName,
address = address,
direction = CallAttributesCompat.DIRECTION_INCOMING,
callType = CallAttributesCompat.CALL_TYPE_AUDIO_CALL,
callCapabilities = (CallAttributesCompat.SUPPORTS_SET_INACTIVE
or CallAttributesCompat.SUPPORTS_STREAM
or CallAttributesCompat.SUPPORTS_TRANSFER),
)
callsManager.addCall(
attributes
) {
// Call control scope
}
From here you will have a call control scope and this scope you can answer, hold, disconnect and get a list of hearable devices.
//call control scope
launch {
availableEndpoints.collect {
.....
}
}
Getting started
Head over to our updated developer guide to get started and try out the Public Alpha release of the Telecom library. Make sure to check out our sample app found on GitHub for a demonstration on how to work with the various APIs.
This sample application implements all the latest features for the Telecom library showing how to do:
- Audio Routing
- Foreground Services
- Accept, Disconnect, Reject and Hold calls
- Watch integration
- CallStyle notification
Feedback
We’d love to hear from you during this Alpha launch to help us shape the library and influence future roadmapping, so please share your feedback and let us know your experience with the library!