> ## 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.

# Actions

> CometChat Calling SDK v5 - Actions for Android

Use call actions to create your own custom controls or trigger call functionality dynamically based on your use case. All actions are called on the `CallSession` singleton instance during an active call session.

## Get CallSession Instance

The `CallSession` is a singleton that manages the active call. All actions are accessed through this instance.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val callSession = CallSession.getInstance()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CallSession callSession = CallSession.getInstance();
    ```
  </Tab>
</Tabs>

<Note>
  Always check `isSessionActive()` before calling actions to ensure there's an active call.
</Note>

## Actions

### Mute Audio

Mutes your local microphone, stopping audio transmission to other participants.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.muteAudio()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.muteAudio();
    ```
  </Tab>
</Tabs>

### Unmute Audio

Unmutes your local microphone, resuming audio transmission.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.unMuteAudio()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.unMuteAudio();
    ```
  </Tab>
</Tabs>

### Set Audio Mode

Changes the audio output device during a call.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.setAudioMode(AudioMode.SPEAKER)
    callSession.setAudioMode(AudioMode.EARPIECE)
    callSession.setAudioMode(AudioMode.BLUETOOTH)
    callSession.setAudioMode(AudioMode.HEADPHONES)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.setAudioMode(AudioMode.SPEAKER);
    callSession.setAudioMode(AudioMode.EARPIECE);
    callSession.setAudioMode(AudioMode.BLUETOOTH);
    callSession.setAudioMode(AudioMode.HEADPHONES);
    ```
  </Tab>
</Tabs>

<Accordion title="AudioMode Values">
  | Value        | Description                                     |
  | ------------ | ----------------------------------------------- |
  | `SPEAKER`    | Routes audio through device loudspeaker         |
  | `EARPIECE`   | Routes audio through phone earpiece             |
  | `BLUETOOTH`  | Routes audio through connected Bluetooth device |
  | `HEADPHONES` | Routes audio through wired headphones           |
</Accordion>

### Pause Video

Turns off your local camera, stopping video transmission. Other participants see your avatar.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.pauseVideo()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.pauseVideo();
    ```
  </Tab>
</Tabs>

### Resume Video

Turns on your local camera, resuming video transmission.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.resumeVideo()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.resumeVideo();
    ```
  </Tab>
</Tabs>

### Switch Camera

Toggles between front and back cameras without interrupting the video stream.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.switchCamera()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.switchCamera();
    ```
  </Tab>
</Tabs>

### Start Recording

Begins server-side recording of the call. All participants are notified.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.startRecording()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.startRecording();
    ```
  </Tab>
</Tabs>

<Warning>
  Recording requires the feature to be enabled for your CometChat app.
</Warning>

### Stop Recording

Stops the current recording. The recording is saved and accessible via the dashboard.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.stopRecording()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.stopRecording();
    ```
  </Tab>
</Tabs>

### Mute Participant

Mutes a specific participant's audio. This is a moderator action.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.muteParticipant(participant.uid)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.muteParticipant(participant.getUid());
    ```
  </Tab>
</Tabs>

### Pause Participant Video

Pauses a specific participant's video. This is a moderator action.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.pauseParticipantVideo(participant.uid)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.pauseParticipantVideo(participant.getUid());
    ```
  </Tab>
</Tabs>

### Pin Participant

Pins a participant to keep them prominently displayed regardless of who is speaking.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.pinParticipant(participant.uid)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.pinParticipant(participant.getUid());
    ```
  </Tab>
</Tabs>

### Unpin Participant

Removes the pin, returning to automatic speaker highlighting.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.unPinParticipant()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.unPinParticipant();
    ```
  </Tab>
</Tabs>

### Set Layout

Changes the call layout. Each participant can choose their own layout independently.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.setLayout(LayoutType.TILE)
    callSession.setLayout(LayoutType.SPOTLIGHT)
    callSession.setLayout(LayoutType.SIDEBAR)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.setLayout(LayoutType.TILE);
    callSession.setLayout(LayoutType.SPOTLIGHT);
    callSession.setLayout(LayoutType.SIDEBAR);
    ```
  </Tab>
</Tabs>

<Accordion title="LayoutType Values">
  | Value       | Description                                           |
  | ----------- | ----------------------------------------------------- |
  | `TILE`      | Grid layout with equally-sized tiles                  |
  | `SPOTLIGHT` | Large view for active speaker, small tiles for others |
  | `SIDEBAR`   | Main speaker with participants in a sidebar           |
</Accordion>

### Enable Picture In Picture Layout

Enables PiP mode, allowing the call to continue in a floating window.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.enablePictureInPictureLayout()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.enablePictureInPictureLayout();
    ```
  </Tab>
</Tabs>

### Disable Picture In Picture Layout

Disables PiP mode, returning to full-screen call interface.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.disablePictureInPictureLayout()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.disablePictureInPictureLayout();
    ```
  </Tab>
</Tabs>

### Set Chat Button Unread Count

Updates the badge count on the chat button. Pass 0 to hide the badge.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.setChatButtonUnreadCount(5)
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.setChatButtonUnreadCount(5);
    ```
  </Tab>
</Tabs>

### Is Session Active

Returns `true` if a call session is active, `false` otherwise.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val isActive = callSession.isSessionActive()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    boolean isActive = callSession.isSessionActive();
    ```
  </Tab>
</Tabs>

### Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.leaveSession()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.leaveSession();
    ```
  </Tab>
</Tabs>

### Raise Hand

Shows a hand-raised indicator to get attention from other participants.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.raiseHand()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.raiseHand();
    ```
  </Tab>
</Tabs>

### Lower Hand

Removes the hand-raised indicator.

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.lowerHand()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.lowerHand();
    ```
  </Tab>
</Tabs>

<Accordion title="Participant Object Reference">
  | Property              | Type      | Description                           |
  | --------------------- | --------- | ------------------------------------- |
  | `uid`                 | `String`  | Unique identifier (CometChat user ID) |
  | `name`                | `String`  | Display name                          |
  | `avatar`              | `String`  | URL of avatar image                   |
  | `pid`                 | `String`  | Participant ID for this call session  |
  | `role`                | `String`  | Role in the call                      |
  | `audioMuted`          | `Boolean` | Whether audio is muted                |
  | `videoPaused`         | `Boolean` | Whether video is paused               |
  | `isPinned`            | `Boolean` | Whether pinned in layout              |
  | `isPresenting`        | `Boolean` | Whether screen sharing                |
  | `raisedHandTimestamp` | `Long`    | Timestamp when hand was raised        |
</Accordion>
