Block Screenshot - FLAG_SECURE Android!


#1

Am working on an app for secure video playback, Is there any option to block screen recorders and screenshots with Expo/ReactNative? if not how can we develop a module to so the job! can someone point me to a right direction?


#2

Hi! Could you be a little more specific about what you need to configure? Is this a field in the android manifest?


#3

Hello @dikaiosune thanks for the repay! No its not something that we write in Manifest. FLAG_SECURE is used in Activity. for example if we want to secure an activity(in android) from being recorded or taking screen shots we can add this code(java) this to do so, I know expo detach will give the ability to write native java codes, but am facing a lot of errors after expo detach. Please help!

public class SomeTestActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                         WindowManager.LayoutParams.FLAG_SECURE);

    setContentView(R.layout.main);
  }
}

#4

Ah I see. I think you’ll need to work with ExpoKit and/or “vanilla” React Native to be able to set those flags on your activities since I believe we don’t expose JS API for that.


closed #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.