---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.ru/doc/en/ad-monetization/dev/android/gdpr.md
  - https://boost.yandex.ru/doc/ru/ad-monetization/dev/android/gdpr.md
  - href: en/ad-monetization/dev/android/gdpr.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.ru/doc/en/llms.txt

# GDPR

## General information {#about}

<!-- source: en/ad-monetization/dev/_includes/gdpr-src.md -->
The General Data Protection Regulation (GDPR) came into effect in the spring of 2018. GDPR regulates how information about citizens of the European Economic Area and Switzerland can be collected and processed. Its intention is to protect the privacy of confidential data and to ensure the transparency of all processes related to the collection, storage and processing of information on the internet.

GDPR has extraterritorial reach and applies to all companies that process personal data of citizens of the European Economic Area and Switzerland, regardless of the company's location.
<!-- endsource: en/ad-monetization/dev/_includes/gdpr-src.md -->

## Quick guide {#instruction}

The user's consent to the processing of their personal data must be passed to the SDK with every app launch.

1. Follow [these steps](https://boost.yandex.ru/doc/en/ad-monetization/dev/android/quick-start.md) to connect the Mobile Ads SDK.

2. Show a window where the user can accept the user agreement for personal data processing (for more information, see the [example](https://github.com/yandexmobile/yandex-ads-sdk-android/tree/master/YandexMobileAdsExample/app/src/main/java/com/yandex/ads/sample)).
   {% note info %}

   This code is a sample, not a step-by-step guide to follow.

   {% endnote %}


   {% list tabs %}
  
    - Kotlin

        ```kotlin
        class GdprDialogFragment : DialogFragment() {
            // ...
            // Example of creating a dialog window.
            override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
                val context = requireContext()
                val builder: AlertDialog.Builder = AlertDialog.Builder(context)
                builder.setTitle(R.string.gdpr_dialog_title)
                    .setMessage(R.string.gdpr_dialog_message)
                    .setPositiveButton(R.string.accept) { _, _ -> onButtonClicked(context, true) }
                    .setNeutralButton(R.string.about) { _, _ -> openPrivacyPolicy() }
                    .setNegativeButton(R.string.decline) { _, _ -> onButtonClicked(context, false) }
                return builder.create()
            }

            private fun openPrivacyPolicy() {
                val url = getString(R.string.privacy_policy_url)
                val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
                startActivity(intent)
            }

            private fun onButtonClicked(context: Context, userConsent: Boolean) {
                val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
                preferences.edit()
                    .putBoolean(SettingsFragment.USER_CONSENT_KEY, userConsent)
                    .putBoolean(SettingsFragment.DIALOG_SHOWN_KEY, true)
                    .apply()
                noticeDialogListener.onDialogClick()
            }
        }
        ```

    - Java

        ```java
        // ...
        public class GdprDialogFragment extends DialogFragment {
            // ...
            // Example of creating a dialog window.
            public Dialog onCreateDialog(Bundle savedInstanceState) {
                final Context context = getContext();

                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle(R.string.gdpr_dialog_title)
                        .setMessage(R.string.gdpr_dialog_message)
                        .setPositiveButton(R.string.accept, (dialog, id) ->
                                onButtonClicked(context, true))
                        .setNeutralButton(R.string.about, (dialog, which) ->
                                openPrivacyPolicy())
                        .setNegativeButton(R.string.decline, (dialog, id) ->
                                onButtonClicked(context, false));
                return builder.create();
            } 

            private void openPrivacyPolicy() {
                final String url = getString(R.string.privacy_policy_url);
                final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(intent);
            }

            private void onButtonClicked(final Context context,
                                         final boolean userConsent) {
                final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
                preferences.edit()
                        .putBoolean(SettingsFragment.USER_CONSENT_KEY, userConsent)
                        .putBoolean(SettingsFragment.DIALOG_SHOWN_KEY, true)
                        .apply();

                mNoticeDialogListener.onDialogClick();
            }
        }
        ```
   {% endlist %}

3. Use the `setUserConsent` method to pass the received value to the Mobile Ads SDK. Data collected from users in GDPR countries is only processed with the user's consent.
