Setting FLAG_SECURE does not work when added to onPause in Android 11

3k Views Asked by At

So I have been trying to hide content in my react native application when my app is visible on the app switcher when i go to recent apps.Initially I set FLAG_SECURE on onCreate but the issue there was i wasn't able to use BrowserStack usage, screenshots and screen recordings were blocked when using the app therefore I resorted to a solution where I set the FLAG_SECURE only when the onPause cycle is triggered and onResume I clear the flag, but there were limitations like Android 8 and below it wasn't supported(which i can live with) but now the solution doesn't work for new Android versions like 11 and on Android 10(on some devices ie Pixel)

1

There are 1 best solutions below

0
IEatSandvich On

https://issuetracker.google.com/issues/123205795

In short, and in case you haven't come across a 'fix' yet, Gesture navigation doesn't handle FLAG_SECURE all too well. You should see the expected behaviour after switching to 3-button navigation.

I get this isn't an actual fix but it doesn't seem like there's much to be done about it.