Phone Calls
Use this component when you want to build an app that would enable your users to Make, Receive and Notify Phone Calls from/in their cars.
How to implement Phone Calls functionality?
The following sections cover how you can get started using Phone Calls functionality. You can easily integrate the Phone Calls, by following these steps.
1. Dependencies
Open the build.gradle file for your project and add the following dependencies:
1 2 3 4 5 6 7 8 9 10 |
|
2. Receive Phone Calls and Notify Incoming Phone Calls
Important
In order to receive notifications, the app using the incoming (android-sdk-phonecall-notification) sdk needs to be set as Dialer app.
Permissions
Set the permision in order to be notified when the state of the call gets changed. (e.g Ringing -> Answered)
Set the permision to read the phone number.
3. Handle Phone Calls
In order to handle the phone calls, follow these steps:
1.Create a provider
The context Parameter represents the context of application.
1 |
|
2.Add a listener to the 'IncomingCallManager'
Once a call is received, the 'onCallStatusUpdate' callback will be notified. The phoneCallListener Parameter is an object that implements the PhoneCallStatusListener interface.
1 |
|
Register for Incoming Phone Call notifications.
The PhoneCallProvider is the entry point for Phone Call notifications.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
4. Interact with Phone Calls
Accept, Reject
Functionality is available in IncomingPhoneCallActionManager which is retrieved from the 'provider' instance.
Permissions
Set the permision in order to be notified when the state of the call gets changed. (e.g Ringing -> Answered)
Set the permision to read the phone number.
Retrieve the IncomingPhoneCallActionManager for accept and reject.
1 |
|
Answer
Answer a call by passing the id of the call. The callId is retrieved from the phoneCallListener#onCallStatusUpdate.
1 |
|
Reject
Reject a phone call by passing the id of the call. The id is retrieved from phoneCallListener#onCallStatusUpdate.
1 |
|
Reject a phone call with a message by passing the id of the call and the message we want to send to the caller. The id is retrieved from phoneCallListener#onCallStatusUpdate . If you call the api with an empty call id or an empty message, an IllegalArgumentException will appear.
1 |
|
Important
Always 'dispose' when provider is no longer needed, like when exiting the app. This frees caches, removes broadcast receivers, etc.:
1 |
|
Hold, Mute, End
This functionality is available in OngoingPhoneCallActionManager, retrieved from the provider instance.
Permissions
Set the permision in order to be notified when the state of the call gets changed. (e.g Ringing -> Answered)
Set the permision to read the phone number.
Info
Retrieve the OngoingPhoneCallActionManager and use it to act upon the ongoing call: end, mute, unmute, hold, untold etc.
1 |
|
Hold
Put a call on hold. The callId Parameter represents the identifier for the call to be put on hold.
1 |
|
Get back into a call. The callId Parameter represents the identifier for the call the user wants to get back into.
1 |
|
Mute
Mute the microphone for the current call.
1 |
|
Unmute the microphone for the current call.
1 |
|
Terminate
Terminate a call. The callId Parameter represents the identifier for the call to be terminated.
1 |
|
Important
Always 'dispose' when provider is no longer needed, like when exiting the app. This frees caches, removes broadcast receivers, etc.
1 |
|
5. Make a Phone Call
Permissions
This permission is required by the dial api.
Phone dialing
Create a phone call dialer provider.
1 |
|
Dial a phone number. It returns: [Success] if a call is successfully placed, [Error] if there was an error.
1 |
|
Dial a contact. It returns a PhoneCallResult as follows: [Success] if a call is successfully placed, [Error] if there was an error.
1 |
|
Places a call for the provided Contact and phone number type, for example Home or Work. Params: contact - a Contact object, numberType - an int. It returns a PhoneCallResult as follows: [Success] if a call is successfully placed, [Error] if there was an error.
1 |
|