diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt index 83d8bc287e3..0894abf74e1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt @@ -220,6 +220,15 @@ public class ReactModalHostView(context: ThemedReactContext) : private fun getCurrentActivity(): Activity? = (context as ThemedReactContext).currentActivity + private fun isFlagSecureSet(activity: Activity?): Boolean { + if (activity == null) { + return false + } + + val flags = activity.window.attributes.flags + return (flags and WindowManager.LayoutParams.FLAG_SECURE) != 0 + } + /** * showOrUpdate will display the Dialog. It is called by the manager once all properties are set * because we need to know all of them before creating the Dialog. It is also smart during updates @@ -293,6 +302,11 @@ public class ReactModalHostView(context: ThemedReactContext) : if (hardwareAccelerated) { newDialog.window?.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) } + val flagSecureSet = isFlagSecureSet(currentActivity) + if (flagSecureSet) { + newDialog.window?.setFlags( + WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) + } if (currentActivity?.isFinishing == false) { newDialog.show() updateSystemAppearance()