> For the complete documentation index, see [llms.txt](https://docs.talsec.app/freerasp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.talsec.app/freerasp/freerasp/integration/android/api.md).

# API

## Variables

### `TalsecConfig`

Specifies configuration for your app. See the table below for a detailed description of the attributes.

<table><thead><tr><th>field</th><th width="137">type</th><th>description</th><th>sample value</th></tr></thead><tbody><tr><td>expectedPackageName</td><td>String</td><td>Package name of the app.</td><td><code>"app.talsec.demo.freerasp"</code></td></tr><tr><td>expectedSigningCertificateHashBase64</td><td>Array&#x3C;String></td><td>Certificate hashes of your app. <strong>You must get your expected signing certificate hashes in Base64 form.</strong> You can go through <a href="/pages/zz0h9wgWeOGlbfnIf8QN">this manual</a> to learn how to sign your app in more detail, including manual signing and using Google's Play app signing. </td><td><code>arrayOf( "mVr/qQLO8DKTwqlL+B1qigl9NoBnbiUs8b4c2Ewcz0k=")</code></td></tr><tr><td>watcherMail</td><td>String?</td><td><p>The value is automatically used for Security Reports, Product Updates, and Talsec Portal updates, <a href="/pages/nXeUfFQHrJJCKXvo5ytH">learn more</a>.</p><p> Mail has a strict form <code>'name@domain.com'</code>.</p></td><td><code>"john@example.com"</code></td></tr><tr><td>supportedAlternativeStores</td><td>Array&#x3C;String></td><td>Package names of the alternative stores on which you are publishing the application. The Google Play Store and Huawei AppGallery, are included internally. (You can assign just <code>emptyArray()).</code> For more information, visit the <a href="https://github.com/talsec/Free-RASP-Community/wiki/Threat-detection#detecting-unofficial-installation">Detecting Unofficial Installation</a> wiki page.</td><td><code>arrayOf( "com.sec.android.app.samsungapps")</code></td></tr><tr><td>isProd</td><td>Boolean?</td><td><p>Defaults to <code>true</code> when undefined. If you want to use the <strong>Dev</strong> version to make the development process viable, set the parameter to <code>false</code>. Make sure that you have the <strong>Release</strong> version in the production (i.e. isProd set to true)!. To simplify switching between debug and release version of freeRASP based on the build type, you can use <code>BuildConfig.BUILD_TYPE.contains("Release", true)</code> as a value for <code>isProd</code>.</p><p><br></p></td><td><code>true</code></td></tr><tr><td>killOnBypass</td><td>Boolean?</td><td><p>Defaults to <code>false</code> .</p><p></p><p>Determines whether the app should be killed within the SDK, if the callbacks are hooked or modified by an attacker.</p></td><td><code>true</code></td></tr></tbody></table>

***

## Classes

### `class ThreatListener`

#### Constructor

`constructor(threats: ThreatDetected, deviceState: DeviceState? = null, executionState: RaspExecutionState? = null)`

* Listener for the threats detected by freeRASP.

#### Methods

`fun registerListener(context: Context)`

* Registers your reactions to detected threats with freeRASP.

`fun unregisterListener(context: Context)`

* Unregisters the reactions to detected threats.

### object Talsec

#### Methods

`fun start(context: Context, config: TalsecConfig, mode: TalsecMode? = TalsecMode.BACKGROUND)`

* The method used to start freeRASP's functionality. `TalsecMode` is an optional parameter that can be used to force the execution of freeRASP in `FOREGROUND` / `BACKGROUND` thread (default value is `TalsecMode.BACKGROUND`).&#x20;

`fun blockScreenCapture(activity: Activity, enable: Boolean)`

* The method used to block/unblock screen capture.

`fun isScreenCaptureBlocked(): Boolean`      &#x20;

* The method used to know the state of screen capture blocking whether blocked or not.

`fun storeExternalId(context: Context, externalId: String): ExternalIdResult`

* Validates and stores a custom identifier (External ID) for the user.
  * **Requirements**:
    * **Allowed characters:** Alphanumeric (a-z, A-Z, 0-9) and special characters: `+`, `_`, `-`, `/`, `:`, `=`.
  * **Returns:**&#x20;
    * `ExternalIdResult.Success` if the ID is valid and stored, or `ExternalIdResult.Error` if the ID violates the requirements (the ID will **not** be stored).

`fun removeExternalId(context: Context)`

* Removes the previously stored External ID.

***

## Abstract Classes

### `public abstract class ThreatDetected`

Sends callbacks to your app when a threat is detected. Read more about the meaning of the callbacks in the [wiki](/freerasp/freerasp/wiki.md).&#x20;

#### Methods:

* `open fun onPrivilegedAccess()`
* `open fun onDebug()`
* `open fun onSimulator()`
* `open fun onAppIntegrity()`
* `open fun onUnofficialStore()`
* `open fun onHooks()`
* `open fun onDeviceBinding()`
* `open fun onObfuscationIssues()`
* `open fun onScreenshot()`
* `open fun onScreenRecording()`
* `open fun onMultiInstance()`
* `open fun onLocationSpoofing()`
* `open fun onTimeSpoofing()`
* `open fun onUnsecureWifi()`
* `open fun onAutomation()`
* `open fun onBootloader()`
* `open fun onMalware(packageInfo: List<SuspiciousAppInfo>)`

{% hint style="info" %}
Methods have default empty implementations, so you only need to override the ones you want to handle.
{% endhint %}

### `abstract class DeviceState`

Provides device state listener to get additional information about device state. Read more about the meaning of the device state listeners in the [wiki](/freerasp/freerasp/wiki.md).&#x20;

#### Methods:

* `open fun onPasscode()`
* `open fun onSecureHardwareNotAvailable()`
* `open fun onDevMode()`
* `open fun onAdbEnabled()`
* `open fun onSystemVpn()`

### `abstract class RaspExecutionState`

A class which represents a set of callbacks that are used to notify the application when state of executing RASP checks changes.

#### Methods:

* `open fun onAllChecksFinished()`

### `sealed interface ExternalIdResult`

Represents the result of the storeExternalId operation.

#### Subclasses:

* `class Success` - Indicates that the externalId was successfully validated and stored.
* `class Error(val errorMsg: String)` - Indicates that validation failed due to invalid characters. Contains a description of the error.


---

# 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.talsec.app/freerasp/freerasp/integration/android/api.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.
