android / android/nowinandroid

FLAG_SECURE not working on Google Pixel devices

Open
#2,132 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is there a StackOverflow question about this issue?

- [x] I have searched StackOverflow

### What happened?

I am developing an Android application using the View/XML approach and need to prevent screenshots and screen recordings. To achieve this, I have enabled FLAG_SECURE using:

window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)

window?.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
This works as expected on most devices, where screenshots and screen recordings are blocked successfully.

However, I have observed different behavior on Google Pixel devices (tested on Pixel 4 and Pixel 9). When a video is played in fullscreen mode using JW Player, users are still able to capture the screen, suggesting that FLAG_SECURE is not being enforced for the fullscreen video view.

Am I missing any additional configuration or implementation step for fullscreen video playback with JW Player? Does JW Player create a separate window/activity that requires FLAG_SECURE to be applied separately?

Additional details:

UI framework: View/XML (not Compose)

Video player: JW Player

Devices tested: Google Pixel 4 and Pixel 9

Android versions: 16 & 13

No errors or crashes are observed; the issue is only that screen capture is not blocked during fullscreen playback.

What could be causing FLAG_SECURE to be ineffective in this specific fullscreen video scenario on Pixel devices?

### Relevant logcat output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

No repository file or test is identified. Start by reproducing fullscreen JW Player playback on the tested Pixel devices with the shown FLAG_SECURE calls, then determine whether fullscreen uses a separate window or activity and verify that screen capture is blocked before proposing a repository change.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.