Skip to content

Consent Screen

Consent screens are used in mobile applications to ask a user's permission before doing something, such as collecting information about the user.

Launch Screen

Features

  • One or multiple consent pages.
  • The user can skip giving consent for optional consent screens.
  • The user can be forced to read all content before moving the next consent screen.
  • External links can be provided on a consent screen to open the content in a browser.

Layout

  • Header: A Close button and an optional Skip button, which will only be shown if the screen type is OPTIONAL
  • Footer: Previous and Next buttons, and the current page number. Footer is only displayed when there are multiple pages. The Next button will not be displayed if the screen type is FORCE_READ_ALL and the content is not scrolled to the bottom
  • Content: The middle part of the screen is used to present the information. Allow and Deny buttons will only appear on the last page

Examples

The following example code builds an OPTIONAL content screen, which has a Skip button on the toolbar.

val contentScreen = ConsentScreen(getTargetContext())
val settings = ConsentScreenSettings.Builder()
    .setScreenType(ConsentScreenSettings.ScreenType.OPTIONAL)
    .addContentPage(
        ConsentScreenSettings.ContentPage(
            getString(R.string.get_usage_permission_title),
            getString(R.string.get_usage_permission_explanation),
            null, null
        )
    ).build()
contentScreen.setSkipButtonOnClickListener {
    ...
}
contentScreen.initialize(settings)
ConsentScreen screen = new ConsentScreen(getTargetContext());
screen.setSkipButtonOnClickListener(v -> {
    ...
});
ConsentScreenSettings css = new ConsentScreenSettings.Builder()
        .setScreenType(ConsentScreenSettings.ScreenType.OPTIONAL)
        .addContentPage(new ConsentScreenSettings.ContentPage(
            getString(R.string.get_usage_permission_title),
            getString(R.string.get_usage_permission_explanation),
            null, null))
        .build();
screen.initialize(css);
setContentView(screen)

The following example code builds a FORCE_READ_ALL content screen with multiple pages, the Next button in the footer shows only when the content view is scrolled to the bottom, indicating user reads all the content. The last page has a Learn More link.

val pages: MutableList<ConsentScreenSettings.ContentPage> = mutableListOf()
for (i in 0..1) {
    pages.add(
        ConsentScreenSettings.ContentPage(
            Integer.toString(i),
            String.format("%d ", i) + getString(R.string.content_body),
            null, null
        )
    )
}
pages.add(
    ConsentScreenSettings.ContentPage(
        "2",
        "2 " + getString(R.string.content_body),
        "LEARN MORE",
        "http://www.sap.com"
    )
)
val css: ConsentScreenSettings = Builder()
    .setScreenType(ConsentScreenSettings.ScreenType.FORCE_READ_ALL)
    .addContentPage(pages[0]).addContentPage(pages[1]).addContentPage(pages[2])
    .build()
contentScreen.initialize(css)
List<ConsentScreenSettings.ContentPage> pages = new ArrayList<>();
for (int i = 0; i < 2; i++) {
    pages.add(new ConsentScreenSettings.ContentPage(
            Integer.toString(i),
            String.format("%d ", i) + context.getString(R.string.content_body),
            null, null
    ));
}
pages.add(new ConsentScreenSettings.ContentPage(
        "2",
        "2 " + context.getString(R.string.content_body),
        "LEARN MORE",
        "http://www.sap.com"
));
ConsentScreenSettings css = new ConsentScreenSettings.Builder()
        .setScreenType(ConsentScreenSettings.ScreenType.FORCE_READ_ALL)
        .addContentPage(pages.get(0)).addContentPage(pages.get(1)).addContentPage(pages.get(2))
        .build();
contentScreen.initialize(css);

The default screen type is REQUIRED, which mean the Skip button will not be shown on the screen.


Last update: August 12, 2020