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

# Events & callbacks

> Handle SDK events like acceptance, decline, and errors using listener callbacks in Android.

The ClickTerm Android SDK uses **listener callbacks** to communicate results. The `show()` and `showAcceptedContent()` methods accept listener interfaces that fire on success or error.

## Show result

When `ClicktermDialog.show()` completes:

```java theme={null}
ClicktermDialog.show(this, request, null,
    new ClicktermDialog.OnAgreementResultListener() {
        @Override
        public void onSuccess(String clicktermSignature) {
            if (clicktermSignature != null) {
                // User accepted or declined — send Signature to your backend
                sendToBackend(clicktermSignature);
            } else {
                // User already accepted the latest major version — no dialog was shown
                Log.i("Clickterm", "Already accepted.");
            }
        }

        @Override
        public void onError(String message) {
            // SDK or network error
            Log.e("Clickterm", message);
        }
    }
);
```

### Possible outcomes

| Outcome               | Callback    | `clicktermSignature` value                                  |
| --------------------- | ----------- | ----------------------------------------------------------- |
| User accepts          | `onSuccess` | Non-null Signature string — send it to your backend         |
| User declines         | `onSuccess` | Non-null Signature string — verify it to record the decline |
| User already accepted | `onSuccess` | `null` — no dialog was shown, no action needed              |
| Error                 | `onError`   | N/A — `message` contains the error description              |

<Note>
  A `null` Signature in `onSuccess` means the user has already accepted the latest major version.
  No action is needed on your part.
</Note>

## Error handling

Errors are delivered via the `onError` callback:

```java theme={null}
@Override
public void onError(String message) {
    switch (message) {
        case "SDK not initialized":
            Log.e("Clickterm", "Call ClicktermClient.initialize() first");
            break;
        default:
            Log.e("Clickterm", "Clickwrap error: " + message);
            break;
    }
}
```

Common error scenarios:

| Error               | Cause                                            |
| ------------------- | ------------------------------------------------ |
| SDK not initialized | `ClicktermClient.initialize()` was not called    |
| Template not found  | Template is disabled or has no effective version |
| Network error       | Cannot reach the ClickTerm API                   |

## Show accepted content result

The `showAcceptedContent()` method uses a separate listener:

```java theme={null}
ClicktermDialog.showAcceptedContent(this, request,
    new ClicktermDialog.OnAcceptedContentListener() {
        @Override
        public void onSuccess(ClickwrapTemplateContent content) {
            // content.getContent() returns the accepted agreement text
            Log.i("Clickterm", content.getContent());
        }

        @Override
        public void onError(String message) {
            Log.e("Clickterm", message);
        }
    }
);
```

<Note>
  `showAcceptedContent` only works if the end user has an accepted and verified event for the given template.
</Note>
