# Block Screenshots on a Page

> Turn off screenshots and screen recording for pages that show something private.

- **Applies to:** AppMint and Appwright
- **Source:** the Integration Guide shipped inside the app; this page is generated from it.
- **HTML:** https://freewebtoapk.com/docs/block-screenshots
- **Using AppMint:** wherever the text below says "Appwright", read "AppMint". The two builders share this feature and only the name changes. Steps where the instructions genuinely differ are given separately and labelled.

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

### 1. What 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();
```

### 2. Protect 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.

### 3. In 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.
```

### 4. Do 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.

