> For the complete documentation index, see [llms.txt](https://docs.truecaller.com/truecaller-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.truecaller.com/truecaller-sdk/android/sdk-v2.8.0-deprecating-soon/integrating-with-your-app/implement-callbacks.md).

# Implement Callbacks

7\. Add the following condition in the onActivityResult method `TruecallerSDK.getInstance().onActivityResultObtained( this,requestCode, resultCode, data)`

Copy

```
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == TruecallerSDK.SHARE_PROFILE_REQUEST_CODE) {
       TruecallerSDK.getInstance().onActivityResultObtained(this, requestCode, resultCode, data);
    }
}
```

> Note : In case you passed Fragment in the getUserProfile() method \[ point #6 ], override the onActivityResult() method in your corresponding Fragment

8\. In your selected Activity/Fragment, either make the component implement ITrueCallback or create an instance of it :

Copy

```
private final ITrueCallback sdkCallback = new ITrueCallback() {
    
     @Override
     public void onSuccessProfileShared(@NonNull final TrueProfile trueProfile) {
     }

     @Override
     public void onFailureProfileShared(@NonNull final TrueError trueError) {
     }
     
     @Override
     public void onVerificationRequired(@Nullable final TrueError trueError) {
     }
     
 };
```

*onSuccessProfileShared()* method will be called in either of the following two scenarios : a.) When the user has agreed to share his profile information with your app by clicking on the "Continue" button on the Truecaller dialog b.) When a non Truecaller user is already verified previously on the same device. This would only happen when the **`TruecallerSdkScope#SDK_OPTION_WITH_OTP`** is selected while initialising the SDK to provision for the verification of non-Truecaller users also.

*onFailureProfileShared()* method will be called when some error occurs or if an invalid request for verification is made. You'll get the respective error code as per the details mentioned [here](/truecaller-sdk/android/sdk-v2.8.0-deprecating-soon/integrating-with-your-app/handling-error-scenarios.md).

onVerificationRequired() method will only be called whe&#x6E;**`TruecallerSdkScope#SDK_OPTION_WITH_OTP`** is selected. This will be called when the user is not a Truecaller app user. Also, you'll get a [Nullable TrueError](/truecaller-sdk/android/sdk-v2.8.0-deprecating-soon/integrating-with-your-app/handling-error-scenarios.md) only when TC app is installed and user is logged in. For other cases, it would be null. This optional TrueError can be used to determine the user action that led to initiating manual verification. So using this TrueError, you can get to whether the user pressed on the *footer CTA* on the verification screen OR the *system back* button.

Write all the relevant logic in the above callback methods to handle the scenarios appropriately.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.truecaller.com/truecaller-sdk/android/sdk-v2.8.0-deprecating-soon/integrating-with-your-app/implement-callbacks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
