I don't want users to take screenshot or record screen of my app. I have added secure flag to the window. This prevents user from taking screenshots and recording screen.
If the screen recording is on, my app prevents the content from being recorded but the audio gets recorded.
On some rooted devices, the secure flags may not work as expected. So I just want to detect if any screen recording app/process is running in background so that I can hide sensitive data and prevent it from being recorded.
Is there any way I can detect if the screen recording is on?
Is there any way I can detect if the screen recording is on?
No.
So I just want to detect if any screen recording app/process is running in background so that I can hide sensitive data and prevent it from being recorded.
Since screen recording does not require a recording-specific app or a process (e.g., adb shell screenrecord
), and since you have no way of knowing particular apps or processes that are using the media projection API, this seems impractical. And, on modern versions of Android, you have no way of knowing what other processes are running, anyway. Plus, there is nothing stopping the user from pointing another camera at the device screen and recording its contents that way.
I don't want users to take screenshot or record screen of my app
Then do not write the app. The idea behind FLAG_SECURE
is to help defend the user against third parties, not to defend the developer against the user.