BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Android Telecom Library Aims to Simplify the Creation of Voice and Video Apps

Android Telecom Library Aims to Simplify the Creation of Voice and Video Apps

Available in Alpha, the new Telecom jetpack library simplifies the process of creating voice and/or video calling applications for Android developers by providing several APIs to support common functionality like answering/declining, audio routing, and so on.

To start with, the new library takes care of declaring which foreground services it uses. This means developers will not need to do it explicitly to comply with the new privacy requirements introduced by Android 14. The library will also transparently make sure the call will not be interrupted when the user navigates away from the app.

The Telecom library also provides an API for smart watches to handle user actions such as answering, declining, hanging up, and muting a call. The API seamlessly updates the watch display with information relevant to the call and manages the case where a call comes in while another call is ongoing by giving the user the possibility of holding the current one.

Another major area of functionality provided by the new library is audio routing, so any app using it will not need to use the audio manager to track the device's audio state, obtain a list of available audio devices, etc. The library can list all available endpoints for streaming audio to/from Bluetooth audio devices.

The Telecom library introduces a new CallsManager class that obsoletes the ConnectionService class available in the previous non-Jetpack version of the library, and will require developers a specific migration to leverage all benefits provided by the new one.

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.

The following snippet shows how to add a call with given attributes:

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 

}

Google says the new library will receive many new features in the coming months and is backward compatible down to Android O (API level 26). If you are interested in creating a VoIP app for Android using it, the best place to start from is Google's official sample app, which shows how you can work with the various APIs.

About the Author

Rate this Article

Adoption
Style

BT