Create Free APK

Device features

Block Screenshots on a Page

Let one page in your app turn off screenshots, screen recording and the recents preview - and give it back when the user leaves

AppMintAppwrightBoth builders - the steps below are the same in each.

I am using

1What this does#

One line from your page turns on Android's screen-capture block for the screen the user is looking at:

  • screenshots fail (the user gets Android's "can't take screenshot" message)
  • screen recording and casting show a black frame
  • the app's preview in the recents screen is hidden

What it cannot do - and nothing on Android can - is stop someone photographing the screen with another phone. If you need that, you need a watermark, not a flag.

const b = window.WebToApk || null;

// On the sensitive screen:
b?.setSecureScreen(true);

// Leaving it early (a modal closing, a tab switch inside one page):
b?.setSecureScreen(false);

// Current state:
const locked = b?.isSecureScreen();

2Protect one page, not the whole app#

Protection belongs to the page that asked for it. Appwright releases it the moment the app navigates anywhere else - a new page, a pushState route, a #hash route - so your statement screen can be protected while the rest of the app takes screenshots normally.

That also means a page has to ask again after a reload: a fresh document has not asked for anything yet, and inheriting the last one's answer is how apps end up locked down on screens nobody meant to protect.

3In a single-page app#

Route changes inside one page release protection automatically, so the usual pattern is to assert it when the protected view mounts and let navigation do the rest.

function showStatement() {
  render(statementView);
  window.WebToApk?.setSecureScreen(true);
}

// Nothing to undo on the way out — moving to another route
// releases it. Call setSecureScreen(false) yourself only when
// you hide the sensitive content WITHOUT navigating.

4Do not use a timer for this#

A common idea is to re-assert protection on an interval, say every second, and let it lapse when the page stops asking. It does not work, and it is worth knowing why: Android does not consult your app when the user presses the screenshot buttons. The flag has to already be on the window. Any second where your page is busy, throttled in the background, or between timer ticks is a second in which the screenshot succeeds.

Ask once when the sensitive content appears. Appwright takes protection away when the user leaves.

This page is generated from the Integration Guide inside the app itself, so it says exactly what the current build says. Read it as Markdown.

Checked against the shipped guide on 2026-09-09.