Disable screen capture in android : with complete example

Disable screen capture in android  : with complete example

Generally, when you take a screenshot, you will see a Screen Capture notification in the notification bar and you can see that screenshot in the Gallery app if you click that notification. And some of the android application you can't take a screenshot of the visible screen because of screen secured by the developer.

In this situation you'll see the message in the notification bar or in the Toast over the screen. Older version of android phone shows this message in the notification bar, but now android new version this message appears as Toast message over the screen.

Disable screen capture in android

Now, if you want to prevent this action for your application or any activity, then you just need a few lines of code in your activity. You can use FLAG_SECURE, and then the Notification will be "Can’t take screenshot…….". There is no application level protection. You have to add this code in all the activities that you want to protect.

You just need to add this line in the activity:


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.


This method required to import WindowManager class. After adding this class in your code for the prevents screen capture will be finished, you can see this example:

package com.legendblogs.demo;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {


Disable screen capture message:

Disable screen capture message legend blogs

See this also:

  1. AsyncTask in Android
  2. Determine if device have an Internet Connection
  3. How to add Firebase in android app

Related posts

Write a comment