0

I wanted to restrict screenshots and screen recording in my Unity game. So, I Googled and found that I need to extend

UnityPlayerActivity

and add a FLAG_SECURE in it's OnCreate method. So, I did it:

public class KTExtendedActivity extends UnityPlayerActivity {
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE);
}

}

I exported it as an AAR and added it to Unity game's Manifest.

Now the problem I am facing is that it is blocking screenshots on every device without any problem. But screen recording is exhibiting different behaviours. On Google Pixel 5 running Android 13, the screen recording is black as expected. But on couple of other Android devices running Android 11 and 12, screen recording is not black. It is recording everything although it is blocking screenshots.

If I extend a native activity with my custom created one inside Android Studio, the screen recordings are black for all devices. But not when I add it in Unity.

What could be the problem?

kashif789us
  • 474
  • 8
  • 23

0 Answers0