← All articlesMobile applications

Which Android App Screens to Hide in Screenshots and How to Check

When an Android app moves to the background, the system may save a snapshot of the current screen for the app switcher. If the screen contains sensitive data, you need to decide whether that data may remain in the image. Start by listing the data and user tasks: which values users actually need, when to hide them, and where capture must be blocked. Then check the result in your own app using fictional data. Having a protective API in the code does not, by itself, confirm that the restriction works.

Identify sensitive data and define when it may be shown

OWASP ties the need for protection to sensitive content and situations where capture must be prevented or data should be hidden. There is no requirement to protect every screen indiscriminately. For each screen, record which values it displays and why users need them for the current task. Consider separately any states in which users temporarily reveal a full value.

The trust boundary here lies between displaying data inside the app for a specific action and allowing it to appear in a screenshot or app switcher image. Permission to view a value while using the app should not automatically be treated as permission to leave it in such an image. Define the expected behavior in advance so that developers and testers assess the same outcome.

First, reduce the amount of exposed data

OWASP recommends showing only the portion of a sensitive value needed for the current task, masking it by default, and hiding it again after use. Start with the interface content: does the screen really need to display the full value continuously, or is part of it sufficient? For each field that can be revealed, describe when it becomes visible and what causes it to be hidden again.

Masking and screenshot restrictions address related concerns. Masking determines what users see in the interface; capture restrictions determine whether the window content may be captured. If a full value is needed briefly, include that state in your checks. Testing only the initial, masked screen leaves an important scenario unassessed.

Choose a restriction and account for its limits

FLAG_SECURE is an Android window flag that prevents screenshots and the display of window content on a non-secure display, such as during casting. Android documentation also describes its use when an app moves to the background: the resulting snapshot is blank. Use this description as the expected outcome for the corresponding test scenario.

For snapshots taken when an app moves to the background, OWASP separately lists checking the use of setRecentsScreenshotEnabled. However, the presence of this name in the code does not prove the actual result. FLAG_SECURE also cannot be considered reliable protection against overlay attacks. The documentation also notes cases where active screen recording is not detected correctly, so universal protection against recording cannot be promised.

Work through a fictional example

Imagine an entirely fictional app called ‘Practice Wallet.’ In a test environment owned by the team, an account screen shows a made-up account number, a fictional balance, and a synthetic transaction history. The team considers these fields sensitive and decides that the number should be partially visible by default, the full value should be revealed only for the action that requires it, and the screen content should not remain in the recent apps list.

Turn that decision into testable conditions. The number is masked in the initial state; it is hidden again after the action is complete; and sensitive fields are absent from the app switcher image when the app moves to the background. If FLAG_SECURE is selected, check separately that ordinary screenshots are blocked. These are conditions for this learning example, not universal requirements for all financial apps.

Check the result while the app is running

OWASP lists a runtime check for sensitive content appearing in snapshots when an app moves to the background. Define a sequence of actions for each selected screen and its sensitive states. Use only your own app, an authorized test environment, and synthetic data that you own.

  • Open the screen and compare its masking with the expectation recorded in advance.
  • Reveal the test value for the intended action and check that it is hidden again after use.
  • Check an ordinary screenshot separately from the image in the recent apps list.
  • Move the app to the background from both the initial state and the state with a revealed value; inspect the app switcher.
  • If you assess recording or casting, record the observed behavior separately, taking the documented limitations into account.
  • Record the tested build, device, sequence of actions, expected result, and actual result.

Prioritize fixes by risk and verify changes

Prioritize any sensitive values found in captured images. Then address unnecessary display of full values and failures to mask them again after use. For each defect, identify the specific screen, state, and unmet expectation. This is more useful than a general comment that ‘screenshot protection does not work.’

Check that the chosen window restriction is applied and that setRecentsScreenshotEnabled is used wherever your solution calls for it. After a fix, repeat the scenario that exposed the problem. Repeat the affected checks after changes to the interface or the logic for revealing data as well. A successful result applies to the tested conditions and does not confirm protection against every capture method.

Document the results and scope of testing

The outcome should be a clear decision table covering the screen, sensitive data, permitted amount of visible data, capture restriction, and test result. Record known limitations too, especially those involving screen recording and overlays. This allows the product owner to see which requirements have been met and which scenarios still need work.

If your product has a website or web component, you can start with a free website or web-product audit from CheckMyApp. The Android checks described here are a separate mobile app testing task; conclusions about the app must be supported by your own runtime test results.

Sources and documentation

  1. Secure sensitive activities — Android Developers
  2. OWASP MASWE-0038: Sensitive data in screenshots and recordings
CheckMyApp

Check your application’s security.

Enter your web application address and email. Get a free preliminary report and choose the depth of analysis.

Check for free