---
title: "Android SDK: Frontend tools"
description: "Connect AI agent frontend tools to your application with the Gleap Android SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/469-android-sdk-frontend-tools
collection: "Android"
updated: 2026-11-01
language: en
---

# Android SDK: Frontend tools

Connect AI agent frontend tools to your application with the Gleap Android SDK. Follow the integration code examples.

Frontend tools let your AI agent execute actions directly inside your app — initiating a transfer, resetting a password, cancelling an order, etc.

Define the tool under AI agents → your agent → Settings → Tools → Add tool → Frontend tool. Its name, description, parameters and execution mode live there. Your app registers the matching runtime handler. See the linked help guide for the current setup. [Frontend tools setup guide](https://help.gleap.ai/en/articles/251-let-an-agent-run-actions-inside-your-app)

## Register a tool handler

Register the handler for a dashboard-defined Frontend tool. Use the tool's runtime name shown in the tool editor.

```java
Gleap.getInstance().registerAgentTool("send-money", new GleapAgentToolHandler() {
    @Override
    public void execute(JSONObject params, GleapAgentToolResultCallback callback) {
        String amount = params.optString("amount");
        String contact = params.optString("contact");

        // Run your own logic here.

        // Return a string or JSON — the AI waits for this response.
        callback.onResult("The transfer was initiated. The user must confirm it in the banking app.");
    }
});
```

Or with Kotlin:

```kotlin
Gleap.getInstance().registerAgentTool("send-money") { params, callback ->
    val amount = params.opt("amount")

    // Run your own logic here.

    // Return a string or JSON — the AI waits for this response.
    callback.onResult("The transfer was initiated. The user must confirm it in the banking app.")
}
```

**Handler contract**

-   The handler receives the parameters configured in the dashboard as a `JSONObject`, filled with the values the AI collected.
    
-   Call the callback exactly once with the result — a `String` or a `JSONObject` / `JSONArray` (stringified automatically). The result is sent back to the AI, which uses it to reply.
    
-   The callback can be invoked asynchronously from any thread — the AI waits for it.
    
-   Exceptions thrown by the handler are caught and reported to the AI automatically.
    
-   If no handler is registered for a tool, the AI is informed so it can respond accordingly.
    

## Execution modes

Set per tool in the dashboard:

-   `Auto` — the handler runs immediately when the AI calls the tool.
    
-   `Ask before final execution` — the AI adds a confirmation button to its reply; the handler only runs after the user confirms.
    

## Migrating from `setAiTools`

`Gleap.getInstance().setAiTools(...)` and the `GleapAiTool` / `GleapAiToolParameter` classes have been removed. Tools defined via `setAiTools` could only return a static response to the AI — Frontend tools execute real code and return live results. Define your tools on the AI agent in the dashboard and register their handlers via `registerAgentTool(name, handler)` instead. The `setAiToolExecutedCallback` callback remains available.

## Related

- [Android SDK setup](https://docs.gleap.ai/en/articles/466-android-sdk-setup.md)
- [Android SDK: User identity](https://docs.gleap.ai/en/articles/467-android-sdk-user-identity.md)
- [Android SDK: Callbacks](https://docs.gleap.ai/en/articles/468-android-sdk-callbacks.md)
- [Android SDK: Forms](https://docs.gleap.ai/en/articles/470-android-sdk-forms.md)
- [Android SDK: Feedback button](https://docs.gleap.ai/en/articles/471-android-sdk-feedback-button.md)
