Skip to main content
Quick Reference for AI Agents & Developers
// Build call log request
val callLogRequest = CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build()

// Fetch call logs
callLogRequest.fetchNext(object : CometChatCalls.CallbackListener<List<CallLog>>() {
    override fun onSuccess(callLogs: List<CallLog>) { /* Display logs */ }
    override fun onError(e: CometChatException) { }
})

// Get specific call details
CometChatCalls.getCallDetails(sessionID, callback)
Available via: SDK | REST API | Dashboard

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 the CallLogRequestBuilder. This builder allows you to customize the call log fetching process according to your needs.
CallLogRequest callLogRequest = new CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build();
CallLogRequestBuilder has the following settings available.
SettingDescription
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

The fetchNext() method retrieves the next set of call logs.
val callLogRequest = CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build()

callLogRequest.fetchNext(object : CometChatCalls.CallbackListener<List<CallLog>>() {
    override fun onSuccess(callLogs: List<CallLog>) {
        // Handle the fetched call logs
    }

    override fun onError(e: CometChatException) {
        // Handle the error
    }
})

Fetch Previous

The fetchPrevious() method retrieves the previous set of call logs.
val callLogRequest = CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build()

callLogRequest.fetchPrevious(object : CometChatCalls.CallbackListener<List<CallLog>>() {
    override fun onSuccess(callLogs: List<CallLog>) {
        // Handle the fetched call logs
    }

    override fun onError(e: CometChatException) {
        // Handle the error
    }
})

Get Call Details

To retrieve the specific details of a call, use the getCallDetails() method. This method requires the session ID and a callback listener.
val sessionID = "SESSION_ID"
CometChatCalls.getCallDetails(sessionID, object : CometChatCalls.CallbackListener<List<CallLog>>() {
    override fun onSuccess(callLogs: List<CallLog>) {
        // Handle the fetched call details
    }

    override fun onError(e: CometChatException) {
        // Handle the error
    }
})
Note: Replace "SESSION_ID" with the ID of the session you are interested in.

Best Practices

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.
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.
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.
Show call duration, status (missed, rejected, completed), and timestamps in your UI to help users quickly understand their call history.

Next Steps