warnerque
warnerque

Reputation: 83

How to programmatically stop a screen video recorder from recording an Android app

I don't want anyone to use a screen recording app on their Android phone to VIDEO record my app's screen. I know screen capture can be prevented, but what about video?

Upvotes: 0

Views: 2363

Answers (1)

Basi
Basi

Reputation: 3158

By adding FLAG_SECURE into your Activity You can secure screen capturing functionality

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

write above setContenView();

from documentation

Android 5.0 lets you add screen capturing and screen sharing capabilities to your app with the new android.media.projection APIs. This functionality is useful, for example, if you want to enable screen sharing in a video conferencing app.

The new createVirtualDisplay() method allows your app to capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network. The API only allows capturing non-secure screen content, and not system audio. To begin screen capturing, your app must first request the user’s permission by launching a screen capture dialog using an Intent obtained through the createScreenCaptureIntent() method.

and Also from this documentation says

Window flag: treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.

NB If you are using SurefaceView with media player then use SurfaceView.setSecure(true), then your video will be secured from any other apps.

Upvotes: 2

Related Questions