Posted by Luke Hopkins – Developer Relations Engineer
At the moment we’re thrilled to announce that the Telecom jetpack library is now in alpha for builders who have already got or are keen on 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 quite a lot of Telecom options, together with:
Platform synchronization
For surfaces like watches, this library permits the consumer to reply, decline, dangle up and mute your name by a easy API, in addition to displaying helpful info akin to who the caller is.
That is additionally useful as a result of if the machine is conscious of your name, ought to different calls such a PTSN/SIM primarily based name come by, you may give the consumer an opportunity to carry the decision they’re at the moment on.
Devoted foreground assist
With the adjustments to Android 14, which require functions to specify foreground service varieties, this library takes care of the necessities for you. For extra info, please confer with the foreground service documentation.
Foreground assist permits customers to remain related to their calls even after the consumer has navigated away out of your app… You gained’t must construct your personal foreground companies or fear concerning the background state of your utility.
Audio Routing
As an alternative of utilizing the audio supervisor to trace state, focus and acquire a listing of audio units, this Telecom library will record all accessible endpoints to your utility 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 units.
Backwards Compatibility
Backwards compatibility works all the best way all the way down to Android O (API Degree 26) on units which assist the Telecom stack which suggests implementing the easy API floor under helps a variety of units.
callsManager.addCall(
attributes,
onIsCallAnswered,
onIsCallDisconnected,
onIsCallActive,
onIsCallInactive
){
val callScope=this
}
You too can question the packagemanager to know if the machine helps Telecom.
packagemanager.hasSystemFeature(PackageManager.FEATURE_TELECOM)
Why use this library over Platform API
You is likely to be pondering, why make this transfer to a brand new library after I might simply equally migrate the deprecated APIs to the brand new APIs added in Android 14. Effectively this library affords:
New Options
We may have extra thrilling additions coming to the Telecom library within the coming months that are unique to the jetpack library. These included expanded assist for VoIP Name actions akin to with the ability to regionally mute the VoIP app for the precise name and with the ability to show the identify of the speaker on one other floor akin to Android Auto. We even have a brand new function coming quickly that may permit customers to switch their ongoing VoIP calls between their telephones and tablets.
Backward Compatibility
As beforehand acknowledged, this library helps backward compatibility, which implies that your app won’t solely be supported on a wider vary of units, however we will resolve interoperability points with older Android variations.
A easy API floor and a big protection of units, means this library is the goto answer for calling functions.
Migrating from ConnectionService to CallsManager
Even when you have already got an present ConnectionService integration to your VoIP app, you must take into account migrating to CallsManager, as talked about above we have now quite a lot of thrilling options coming to this library and utilizing the jetpack library provides you with a easy and full answer shifting ahead.
Migrating from ConnectionService to CallManager is pretty simple to implement however shouldn’t be a easy case of adjusting namespace. You’ll be able to consider CallManager representing ConnectionService and CallControlScope representing ConnectionService.
Under exhibits the distinction between learn how to swap audio utilizing connection service to CallControlScope.
You too can question the packagemanager to know if the machine helps Telecom.
cconnectionService.setAudioRoute (int route)
when (requestEndpointChange(newEndpoint)) {
is CallControlResult.Success -> {
// Gadget modified
}
is CallControlResult.Error -> {
}
}
One other instance displaying 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,
route = 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’ll have a name management scope and this scope you’ll be able to reply, maintain, disconnect and get a listing of hearable units.
//name management scope
launch {
availableEndpoints.accumulate {
.....
}
}
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 to take a look at our pattern app discovered on GitHub for an indication on learn how to work with the assorted APIs.
This pattern utility implements all the newest options for the Telecom library displaying learn how to do:
- Audio Routing
- Foreground Providers
- 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!