Posted by Luke Hopkins – Developer Relations Engineer
Right this moment we’re thrilled to announce that the Telecom jetpack library is now in alpha for builders who have already got or are occupied with creating voice and/or video calling functions. Our purpose with this library is to simplify the developer integration course of and enhance VoIP calling throughout Android surfaces.
androidx.core:core-telecom:1.0.0-alpha02
What’s within the Public Alpha launch
This launch helps a wide range of Telecom options, together with:
Platform synchronization
For surfaces like watches, this library permits the consumer to reply, decline, hold up and mute your name by way of a easy API, in addition to displaying helpful info similar to who the caller is.
That is additionally useful as a result of if the gadget is conscious of your name, ought to different calls such a PTSN/SIM based mostly name come by way of, you may give the consumer an opportunity to carry the decision they’re at the moment on.
Devoted foreground help
With the modifications to Android 14, which require functions to specify foreground service varieties, this library takes care of the necessities for you. For extra info, please check with the foreground service documentation.
Foreground help permits customers to remain related to their calls even after the consumer has navigated away out of your app… You gained’t have to construct your individual foreground providers or fear in regards to the background state of your software.
Audio Routing
As an alternative of utilizing the audio supervisor to trace state, focus and procure a listing of audio gadgets, this Telecom library will record all obtainable endpoints to your software for streaming audio to/from Bluetooth hearables, listening to aids, wired headphones, and different surfaces, thus giving customers entry and management to a variety of hearable gadgets.
Backwards Compatibility
Backwards compatibility works all the way in which right down to Android O (API Degree 26) on gadgets which help the Telecom stack which suggests implementing the straightforward API floor under helps a variety of gadgets.
callsManager.addCall(
attributes,
onIsCallAnswered,
onIsCallDisconnected,
onIsCallActive,
onIsCallInactive
){
val callScope=this
}
It’s also possible to question the packagemanager to know if the gadget helps Telecom.
packagemanager.hasSystemFeature(PackageManager.FEATURE_TELECOM)
Why use this library over Platform API
You may be pondering, why make this transfer to a brand new library once I might simply equally migrate the deprecated APIs to the brand new APIs added in Android 14. Properly this library provides:
New Options
We could have extra thrilling additions coming to the Telecom library within the coming months that are unique to the jetpack library. These included expanded help for VoIP Name actions similar to with the ability to domestically mute the VoIP app for the precise name and with the ability to show the title of the speaker on one other floor similar to Android Auto. We even have a brand new function coming quickly that may enable customers to switch their ongoing VoIP calls between their telephones and tablets.
Backward Compatibility
As beforehand said, this library helps backward compatibility, which signifies that your app won’t solely be supported on a wider vary of gadgets, however we will resolve interoperability points with older Android variations.
A easy API floor and a big protection of gadgets, means this library is the goto answer for calling functions.
Migrating from ConnectionService to CallsManager
Even when you have already got an current ConnectionService integration on your VoIP app, it is best to contemplate migrating to CallsManager, as talked about above now we have a number of thrilling options coming to this library and utilizing the jetpack library will provide you with a easy and full answer shifting ahead.
Migrating from ConnectionService to CallManager is pretty simple to implement however is just not a easy case of adjusting namespace. You’ll be able to consider CallManager representing ConnectionService and CallControlScope representing ConnectionService.
Beneath reveals the distinction between the way to swap audio utilizing connection service to CallControlScope.
It’s also possible to question the packagemanager to know if the gadget helps Telecom.
cconnectionService.setAudioRoute (int route)
when (requestEndpointChange(newEndpoint)) {
is CallControlResult.Success -> {
// System modified
}
is CallControlResult.Error -> {
}
}
One other instance exhibiting how easy this API is to make use of, you’ll be able to add a name to the platform and outline you name attributes with the code under:
val attributes = CallAttributesCompat(
displayName = displayName,
handle = handle,
path = 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
) {
// Name management scope
}
From right here you should have a name management scope and this scope you’ll be able to reply, maintain, disconnect and get a listing of hearable gadgets.
//name management scope
launch {
availableEndpoints.gather {
.....
}
}
Getting began
Head over to our up to date developer information to get began and check out the Public Alpha launch of the Telecom library. Ensure that to try our pattern app discovered on GitHub for an indication on the way to work with the varied APIs.
This pattern software implements all the most recent options for the Telecom library exhibiting the way to do:
- Audio Routing
- Foreground Companies
- Settle for, Disconnect, Reject and Maintain calls
- Watch integration
- CallStyle notification
Suggestions
We’d love to listen to from you throughout this Alpha launch to assist us form the library and affect future roadmapping, so please share your suggestions and tell us your expertise with the library!