# Class AnalyticsConsent

java.lang.Object
com.codename1.analytics.AnalyticsConsent

public final class AnalyticsConsent extends Object
An immutable snapshot of the consent the user has granted, broken down by category so that an application can honour granular choices (for example allowing crash reporting while declining behavioural analytics). Instances are created through `all()`, `none()` or `builder()` and handed to `Analytics.setConsent(AnalyticsConsent)`. An application that has already collected consent elsewhere can unblock everything in one line: `Analytics.setConsent(AnalyticsConsent.all())`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `AnalyticsConsent.Builder`
  Mutable builder for `AnalyticsConsent`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AnalyticsConsent`
  `all()`
  A consent object granting every category.
  `AnalyticsConsent.Builder`
  `asBuilder()`
  Returns a builder seeded with this object's current values so a single category can be toggled without rebuilding from scratch.
  `static AnalyticsConsent.Builder`
  `builder()`
  Creates a builder seeded with all categories denied.
  `static AnalyticsConsent`
  `denied()`
  Alias for `none()`; denying every category.
  `static AnalyticsConsent`
  `granted()`
  Alias for `all()`; granting every category.
  `boolean`
  `isAdStorage()`
  Consent for advertising / ad storage.
  `boolean`
  `isAnalytics()`
  Consent for screen views, events and user properties.
  `boolean`
  `isCrashReporting()`
  Consent for crash and exception reporting.
  `boolean`
  `isPersonalization()`
  Consent for personalization (e.g. user-level identification).
  `static AnalyticsConsent`
  `none()`
  A consent object denying every category.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isAnalytics

    public boolean isAnalytics()

    Consent for screen views, events and user properties.

    ###### Returns

    true if behavioural analytics collection is permitted

  - ### isCrashReporting

    public boolean isCrashReporting()

    Consent for crash and exception reporting.

    ###### Returns

    true if crash reporting is permitted

  - ### isPersonalization

    public boolean isPersonalization()

    Consent for personalization (e.g. user-level identification).

    ###### Returns

    true if personalization is permitted

  - ### isAdStorage

    public boolean isAdStorage()

    Consent for advertising / ad storage.

    ###### Returns

    true if ad storage is permitted

  - ### all

    public static AnalyticsConsent all()

    A consent object granting every category. Use this when the application has already obtained consent through its own mechanism (a custom prompt, a third-party consent-management platform, an enterprise MDM policy, or a jurisdiction where the integrator has determined consent is not required) and simply wants reporting to flow:

        // app handled consent elsewhere -- unblock all categories at startup
        Analytics.setConsent(AnalyticsConsent.all());

    For apps that would rather not gate at all, see `Analytics.setConsentMode(ConsentMode)` with `ConsentMode.OPT_OUT`.

    ###### Returns

    consent with all categories granted

  - ### none

    public static AnalyticsConsent none()

    A consent object denying every category. Equivalent to the implicit state before consent is recorded in `ConsentMode.OPT_IN`.

    ###### Returns

    consent with all categories denied

  - ### granted

    public static AnalyticsConsent granted()

    Alias for `all()`; granting every category.

    ###### Returns

    consent with all categories granted

  - ### denied

    public static AnalyticsConsent denied()

    Alias for `none()`; denying every category.

    ###### Returns

    consent with all categories denied

  - ### builder

    public static AnalyticsConsent.Builder builder()

    Creates a builder seeded with all categories denied.

    ###### Returns

    a new builder

  - ### asBuilder

    public AnalyticsConsent.Builder asBuilder()

    Returns a builder seeded with this object's current values so a single category can be toggled without rebuilding from scratch.

    ###### Returns

    a builder pre-populated from this instance