Quick Reference for AI Agents & Developers
Overview
CometChat’s Android Call SDK provides a comprehensive way to integrate call logs into your application, helping users keep track of their communication history. Call logs provide crucial information such as call duration, participants, and more. This feature allows users to review past interactions and revisit important conversation details. With the flexibility to fetch call logs, filter them by specific parameters, and obtain detailed information about individual calls, you can build a more robust and interactive communication framework. The following sections walk you through working with call logs and how to use this feature effectively in your Android application.Fetching Call Logs
To fetch call logs in your Android application, use theCallLogRequestBuilder. This builder allows you to customize the call log fetching process according to your needs.
CallLogRequestBuilder has the following settings available.
| Setting | Description |
|---|---|
setLimit(int limit) | Specifies the number of call logs to fetch. |
setCallType(@CometChatCallsConstants.CallType String callType) | Sets the type of calls to fetch (audio or video). It accepts CallType Enum with following values CometChatCallsConstants.CallType.CALL_TYPE_VIDEO, CometChatCallsConstants.CallType.CALL_TYPE_AUDIO & CometChatCallsConstants.CallType.CALL_TYPE_AUDIO_VIDEO |
setCallStatus(@CometChatCallsConstants.CallStatus String callStatus) | Sets the status of calls to fetch (initiated, ongoing, etc.). It accepts CallStatus Enum with following values CometChatCallsConstants.CallStatus.CALL_STATUS_ONGOING, CometChatCallsConstants.CallStatus.CALL_STATUS_BUSY, CometChatCallsConstants.CallStatus.CALL_STATUS_REJECTED, CometChatCallsConstants.CallStatus.CALL_STATUS_CANCELLED, CometChatCallsConstants.CallStatus.CALL_STATUS_ENDED, CometChatCallsConstants.CallStatus.CALL_STATUS_MISSED, CometChatCallsConstants.CallStatus.CALL_STATUS_INITIATED, CometChatCallsConstants.CallStatus.CALL_STATUS_UNANSWERED |
| setHasRecording(boolean hasRecording) | Sets whether to fetch calls that have recordings. |
| setCallCategory(@CometChatCallsConstants.CallLogCategory String callCategory) | Sets the category of calls to fetch (call or meet). It accepts CallLogCategory Enum with following values CometChatCallsConstants.CallLogCategory.CALL_CATEGORY_CALL & CometChatCallsConstants.CallLogCategory.CALL_CATEGORY_MEET |
| setCallDirection(@CometChatCallsConstants.CallDirection String callDirection) | Sets the direction of calls to fetch. It accepts CallDirection Enum with following values CometChatCallsConstants.CallDirection.CALL_DIRECTION_INCOMING & CometChatCallsConstants.CallDirection.CALL_DIRECTION_OUTGOING |
| setUid(String uid) | Sets the UID of the user whose call logs to fetch. |
| setGuid(String guid) | Sets the GUID of the user whose call logs to fetch. |
| setAuthToken(String authToken) | Sets the Auth token of the logged-in user. |
Fetch Next
ThefetchNext() method retrieves the next set of call logs.
- Kotlin
- Java
Fetch Previous
ThefetchPrevious() method retrieves the previous set of call logs.
- Kotlin
- Java
Get Call Details
To retrieve the specific details of a call, use thegetCallDetails() method. This method requires the session ID and a callback listener.
- Kotlin
- Java
"SESSION_ID" with the ID of the session you are interested in.
Best Practices
Use Pagination for Large Call Histories
Use Pagination for Large Call Histories
Use
setLimit() to fetch call logs in manageable batches (e.g., 20-50 logs per request). This improves performance and reduces memory usage, especially for users with extensive call histories.Filter Call Logs Appropriately
Filter Call Logs Appropriately
Use filters like
setCallStatus(), setCallType(), and setCallDirection() to show relevant call logs to users. For example, show only missed calls in a “Missed Calls” tab.Cache Call Logs Locally
Cache Call Logs Locally
Store fetched call logs in local storage (Room database or SharedPreferences) to provide offline access and reduce API calls. Refresh the cache periodically or when the app comes to the foreground.
Display Call Duration and Status
Display Call Duration and Status
Show call duration, status (missed, rejected, completed), and timestamps in your UI to help users quickly understand their call history.