> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Call Logs

> CometChat Calling SDK v4 - Stable Release - Call Logs for Android

## Overview

CometChat's Android Call SDK provides a comprehensive way to integrate call logs into your application, enhancing your user experience by allowing users to effortlessly keep track of their communication history. Call logs provide crucial information such as call duration, participants, and more.

This feature not only allows users to review their past interactions but it also serves as an effective tool to revisit important conversation details. With the flexibility of fetching call logs, filtering them according to specific parameters, and obtaining detailed information of individual calls, application developers can use this feature to build a more robust and interactive communication framework.

In the following sections, we will guide you through the process of working with call logs, offering a deeper insight into how to optimally use this feature in your Android application.

## Fetching Call Logs

To fetch all call logs in your Android application, you should use the `CallLogRequestBuilder`, This builder allows you to customize the call logs fetching process according to your needs.

```java theme={null}
CallLogRequest callLogRequest = new CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build();
```

`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

The\*\*`fetchNext()`\*\*method retrieves the next set of call logs.

```java theme={null}
CallLogRequest callLogRequest = new CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build();

callLogRequest.fetchNext(new CometChatCalls.CallbackListener<List<CallLog>>() {
    @Override
    public void onSuccess(List<CallLog> callLogs) {
        // Handle the fetched call logs
    }

    @Override
    public void onError(CometChatException e) {
        // Handle the error
    }
});
```

### Fetch Previous

The\*\*`fetchPrevious()`\*\*method retrieves the previous set of call logs.

```java theme={null}
CallLogRequest callLogRequest = new CallLogRequest.CallLogRequestBuilder()
    .setAuthToken(CometChat.getUserAuthToken())
    .setLimit(50)
    .setCallCategory(CometChatCallsConstants.CALL_CATEGORY_CALL)
    .build();

callLogRequest.fetchPrevious(new CometChatCalls.CallbackListener<List<CallLog>>() {
    @Override
    public void onSuccess(List<CallLog> callLogs) {
        // Handle the fetched call logs
    }

    @Override
    public void onError(CometChatException e) {
        // Handle the error
    }
});
```

## Get Call Details

To retrieve the specific details of a call, use the\*\*`getCallDetails()`\*\*method. This method requires the Auth token of the logged-in user and the session ID along with a callback listener.

```java theme={null}
String sessionID = "SESSION_ID";
CometChatCalls.getCallDetails(sessionID, new CometChatCalls.CallbackListener<List<CallLog>>() {
    @Override
    public void onSuccess(List<CallLog> callLogs) {
        // Handle the fetched call details
    }

    @Override
    public void onError(CometChatException e) {
        // Handle the error
    }
});
```

Note: Replace\*\*`"SESSION_ID"`\*\*with the ID of the session you are interested in.
