# User Consent Screen

Release Version **1.2.3** | Release Date **09/29/2025**

{% hint style="info" %}
Minimum requirements:

* Use the Android API level 22 (Android OS 5.1) and above.&#x20;
  {% endhint %}

{% hint style="warning" %}
The information provided below is not legal advice. Madex is not responsible for the consequences of its use. Before making legally significant decisions, it is recommended to consult with a lawyer.
{% endhint %}

## General Information

To comply with the requirements of app stores and laws regulating the collection, processing, and usage of user personal data, obtaining the user's consent for the mentioned actions is required. If refused, no user data should be collected.

In addition to user consent, you will need to properly prepare a privacy policy and other documents required by app stores and the laws of the countries where your app is published.

Clear consent for the collection, processing, and usage of user data is required by most countries. Here are a few key documents describing this process:

* GDPR (General Data Protection Regulation, Regulation (European Union) 2016/679)
* COPPA (Children's Online Privacy Protection Rule)
* CCPA (California Consumer Privacy Act)

{% hint style="warning" %}
Please note that this list is not exhaustive. It is recommended to study the legislation regulating user personal data in the countries where your app is published and consult with a lawyer before making legally significant decisions.
{% endhint %}

## Consent screen and Consent Manager

Usually, user consent is obtained on a special screen during the first launch of the app — the consent screen.

Madex SDK implements such a screen, and you can add and customize it using the **Consent Manager** library. You can use it to avoid creating the Consent Screen yourself.

## Demo Application

Use our demo application as an example.

{% embed url="<https://github.com/MadexTech/madex-android-demo>" %}

## Installation&#x20;

### Prepare Gradle

1. Install Madex SDK. Detailed installation process is described in the [corresponding section](/madex-documentation/android-sdk/installing-and-configuring-the-sdk.md).
2. Add the dependency for installing Consent Manager to the `build.gradle` file.

```groovy
dependencies {
    // ... other dependencies
    
    // connection of Consent Manager SDK dependency
    implementation 'sspnet.tech.consent:madex:1.2.3'
}
```

3. Save the file and click on `Gradle sync`.

## Setting up Consent Manager

Before using the user consent screen, it needs to be configured.

To set parameters, call the methods of the `builder` variable. Below is a list of all available settings:

* `appendPolicyURL` - sets the link to your app's privacy policy. Consider this parameter as mandatory. Links to Madex's and our partners' privacy policies are already added to the consent screen.
* `appendBundle` - sets a custom Bundle used to set the app's icon in the TopBar of the user consent screen. If the parameter is not filled, the existing app icon will be displayed.
* `appendName` - sets the name of your app in the TopBar of the user consent screen. If the parameter is not filled, the existing app name will be displayed.
* `appendGDPR` - adds a button for refusing data collection.\
  \
  Consent screen with one button: the option to refuse data collection is available to the user only through device settings.\
  \
  ![](/files/TTkH9phGUxTL2ee1Grlj)\
  \
  Consent screen with two buttons: the option to refuse data collection is available to the user by tapping the "No thanks" button.\
  \
  ![](/files/2RHu26mjWLLJ6AzhP8Cn)<br>

Take a look at the complete example of setting parameters:

```java
final ConsentBuilder builder = new ConsentBuilder()
        .appendPolicyURL("https://madex.me/privacy-policies")
        .appendGDPR(true)
        .appendBundle("me.madex.ads.app")
        .appendName("Example name");
        
consentManager.registerCustomVendor(builder);
```

## Working with Consent Manager

### Initialization

Create a `ConsentManager` variable in your `Activity`.

```java
final ConsentManager consentManager = new ConsentManager();
```

We recommend calling SDK initialization in your `MainActivity` - in the `onCreate` method.

```java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    consentManager.loadManager();
}
```

### Displaying the Permissions Request Screen

To display the screen, call the `showConsentWindow` method.

```java
consentManager.showConsentWindow();
```

### Checking the User's Consent Status

If the user has given consent to data collection, the method will return `true`.

```java
consentManager.hasConsent(this);
```

If the method returns `false`, it is strongly recommended not to collect any data about this user.

### Updating the User's Consent Status (SDK method for advertising)

To update the consent status in the Madex SDK (for advertising purposes), use the `setUserConsent` method.

```java
Madex.setUserConsent(consentManager.hasConsent(this));
```

Other Madex SDK methods (for working with ads) can be found in the [corresponding section](/madex-documentation/android-sdk/working-with-advertising.md#sdk-methods).

### Debug Mode

If you need error and event logging, enable debug mode.\
By default, it is turned off.

To enable debug mode, use the `enableDebug` method.

```java
consentManager.enableDebug(true);
```

### Event Tracking

Consent Manager allows you to track events related to user consent for data collection.

To track events, provide a class to work with.

Below is an example of setting up advertising events.

```java
consentManager.setListener(new ConsentListener() {
    @Override
    public void onConsentManagerLoaded() {
        // Called when the manager is ready to show
    }
    
    @Override
    public void onConsentManagerLoadFailed(String error) {
        // Called if there is an error during loading
    }
    
    @Override
    public void onConsentWindowShown() {
        // Called when the screen is displayed
    }
    
    @Override
    public void onConsentManagerShownFailed(String error) {
        // Called if there is an error during screen display
    }
    
    @Override
    public void onConsentWindowClosed(boolean hasConsent) {
        // Called when the screen is closed
        // hasConsent - determines whether the user has given consent
    }
});
```


---

# Agent Instructions: 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:

```
GET https://madex.gitbook.io/madex-documentation/android-sdk/user-consent-screen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
