Phone Calls
Receive Phone Calls and Notify Incoming Phone Calls
Register for Incoming Phone Call notifications.
ℹ️ In order to handle the phone calls, you have to create a PhoneCallProvider
Method |
Details |
PhoneCallProvider.create(Context context) |
Creates the PhoneCallProvider for the given context |
| val provider = PhoneCallProvider.create(context)
|
And register a listener to it
Method |
Details |
subscribe(PhoneCallStatusListener listener,PhoneCallTopic topic) |
Register the listener for receiving phone call updates regarding the specified topic |
| provider.providePublisher().subscribe(phoneCallListener, PhoneCallTopic.ANY)
|
Once a call is received, the 'onCallStatusUpdate' callback will be notified.
Interact with Phone Calls
Accept, Reject
Functionalities is available in 'IncomingPhoneCallActionManager', retrieved from the 'provider' instance.
ℹ️ Retrieve the [IncomingCallManager] for accept and reject
| val incomingCallManager = provider.provideIncomingCallActionManager()
|
Method |
Details |
accept(String callId) |
Accept the incoming call with the specified callId |
reject(String callId) |
Reject the incoming call with the specified callId |
rejectWithMessage(String callId,String message) |
Reject the incoming call with the specified callId and send a message to the caller. Throws IllegalArgumentException - if an empty callId or message is passed |
Hold, Mute, End
This functionality is available in 'OngoingPhoneCallActionManager', retrieved from the 'provider' instance.
ℹ️ Retrieve the 'OngoingPhoneCallActionManager' and use it to act upon the ongoing call: end, mute, unmute, hold, untold etc
| val ongoingCallManager = provider.provideOngoingCallActionManager()
|
Method |
Details |
hold(String callId) |
Put the ongoing call with the specified callId on hold. Throws IllegalArgumentException - if an empty callId is passed |
unhold(String callId) |
Get back into the call with the specified callId. Throws IllegalArgumentException - if an empty callId is passed |
mute() |
Mute the microphone for the current call |
unmute() |
Unmute the microphone for the current call |
end() |
Terminate the call with the specified callId |
playDtmf(String callId,Char digit) |
For the call specified by calldId, play the DTMF tone corresponding to the given digit |
Make a Phone Call
ℹ️ In order to make phone calls, you have to create a PhoneCallDialerProvider and get a PhoneCallDialer instance from it
| val phoneCallDialerProvider = PhoneCallDialerProvider.Factory.create(this).provideDialer()
|
Method |
Details |
dial(String number) |
Dial the specified phone number |
dial(Contact contact) |
Dial the specified contact |
dial(Contact contact,Integer numberType) |
Dial the specified contact on the number corresponding to the numberType (Home, Work) |
ℹ️ All dial methods return a PhoneCallResult.Success if the dial was successful, and PhoneCallResult.Error otherwise
View the Call History
| // Create a phone calls history data access object
val dataAccess = PhoneCallsHistoryDataAccess.Factory().createDataAccess(
context.contentResolver,
PhoneCallsHistoryDataAccess.DataAccessType.BASE
)
|
To query the dataAccess, its find method has to be called
Method |
Details |
find(Query.Builder queryBuilder) |
Returns a list of HistoryRecord filtered as speicified by the queryBuilder |
The available query types for the Query.Builder() are as follows
Method |
Details |
full() |
Filter for full history data |
answered() |
Filter for answered calls |
missed() |
Filter for missed calls |
outgoing() |
Filter for made calls |
rejected() |
Filter for rejected calls |
since(Date date) |
Filter the call history since the given date |
The queries can also be combined, for example:
| // Filter for reading history since the @date filtered by outgoing and missed calls
val queryBuilder = Query.Builder().since(date).outgoing().missed()
|
Clear Phone Calls History
Not yet implemented