How To Disable Screenshot and Screen Recording in Android Application

disable-screenshot-screen-recording-android-studio

In this tutorial we will learn how to prevent someone to take screenshot or record screen on your Android Application.

In some cases , we don’t want to allow to take screenshots or screen recordings of our android application. Here we are going to explain how to How To Disable Screenshot and Screen Recording in Android Application.

This feature is very useful where you don’t want anyone to take screenshot or screen recording. For this we will use FLAG_SECURE in our Main Activity with few line of coding and when someone will try to take screenshot is will toast up with some warning message.

lets see how will do it.

Create a new project

  • Create a new project in Android Studio File–>New–>New Project.
  • Enter Application Name, Package Name, Select Empty Activity and click on finish.

Design your layout

  • Design your project according to your need.

Add code to your activity

  • Open your MainActivity.java file.
  • Copy below code to your activity to Disable Screenshot and Screen Recording in Android Application.

FLAG_SECURE Indicates that the display has a secure video output and supports compositing secure surfaces. Secure surfaces are used to prevent content rendered into those surfaces by applications from appearing in screenshots or from being viewed on non-secure displays. Protected buffers are used by secure video decoders for a similar purpose.

Output result

When someone will try to take screenshot it will popup with toast message.

disable-screenshot-screen-recording-android-studio

Subscribe To Our YouTube Channel

Like Us On Facebook

Android Code Finder

Other Tutorials-

RECENT POST

Leave a Reply

Your email address will not be published. Required fields are marked *