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:
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 |
A null Signature in onSuccess means the user has already accepted the latest major version.
No action is needed on your part.
Error handling
Errors are delivered via the onError callback:
@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:
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);
}
}
);
showAcceptedContent only works if the end user has an accepted and verified event for the given template.