# Get started

## **Prerequisite**

Before starting DriveKit Group module integration, make sure that you have [initialized DriveKit](/get-started-drivekit/android.md), especially if you have [disable the SDK auto-initialization](/get-started-drivekit/android/advanced-configurations.md#manually-initialize-the-sdk).&#x20;

{% hint style="danger" %}
If you use DriveKit Group without having initialized DriveKit, an exception will be generated and the SDK will not work in your application.
{% endhint %}

## Integration

### Get from repository

To add Group module to your app, add the following line to your dependencies in your application build.gradle file:

```gradle
dependencies {
   implementation 'com.drivequant.drivekit:drivekit-group:$drivekit_version'
}
```

{% hint style="info" %}
Replace `$drivekit_version` with the DriveKit version you are using in your app
{% endhint %}

## Initialization

If you have [disabled the SDK auto-initialization](/get-started-drivekit/android/advanced-configurations.md#manually-initialize-the-sdk), an initialization phase is required to use the functions offered by the Group component. To initialize Group component in your app, you must call the initialization method in `onCreate` method of your application class.

{% tabs %}
{% tab title="DriveKitGroup" %}

```kotlin
fun initialize()
```

{% endtab %}
{% endtabs %}

## Synchronise Groups

To obtain the list of groups that belong to your organisation, call the following method:

{% tabs %}
{% tab title="DriveKitGroup" %}

```kotlin
fun getGroups(
    groupType: DKGroupType = DKGroupType.ALL,
    listener: GroupsQueryListener,
    type: SynchronizationType = SynchronizationType.DEFAULT
)
```

{% endtab %}
{% endtabs %}

`GroupsSynchronizationStatus` can have 3 values:

1. `SUCCESS`: synchronization has been successfully performed.
2. `CACHE_DATA_ONLY`: groups previously synchronized are returned.

`DKGroupType` can have 3 values:

1. `ALL`: Get all groups related to user team.
2. `JOINED`: Get already joined groups.
3. `NOT_JOINED`: Get not joined groups related to user team.

## Join Group

To assign the driver to a group, call the following method:

{% tabs %}
{% tab title="DriveKitGroup" %}

```kotlin
fun joinGroup(
    groupId: String,
    listener: JoinGroupQueryListener
)
```

{% endtab %}
{% endtabs %}

`DKJoinGroupStatus` can have 4 values:

1. `SUCCESS`: Group joined successfully.
2. `ALREADY_JOINED`: Group already joined.
3. `GROUP_NOT_FOUND`: Wrong groupId.
4. `FAILED_TO_JOIN`: Failed to join the group.

## Leave Group

To remove the driver from a group to which it has been assigned, call the following method:

{% tabs %}
{% tab title="DriveKitGroup" %}

```kotlin
fun leaveGroup(
    groupId: String,
    listener: LeaveGroupQueryListener
)
```

{% endtab %}
{% endtabs %}

`DKLeaveGroupStatus` can have 4 values:

1. `SUCCESS`: Left group successfully.
2. `NOT_IN_GROUP`: Group already left.
3. `GROUP_NOT_FOUND`: Wrong groupId.
4. `FAILED_TO_LEAVE`: Failed to leave the group.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drivequant.com/group/android/get-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
