1

How to disable taking screen shot in android . My app is inside another container ex: Blackberry container . Im using the blackberry SDK for my app.

Im using the following code:

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

This is not working . If there is any solution please provide. Thanks .

madhu
  • 81
  • 1
  • 8

2 Answers2

2

Try this::

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

Add this line before your setContentView() method.

Description::

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

For more details please check android documentation:

Document

Jaymin
  • 2,879
  • 3
  • 19
  • 35
  • @Jaymin Nice copy paste answer from this post-https://stackoverflow.com/questions/28606689/how-to-prevent-screen-capture-in-android/31406316#31406316, copycat, try to explain the procedure to solve the problem – Ram Koti Feb 15 '18 at 06:24
1

Try This solution.

Use WindowManager.LayoutParams.FLAG_SECURE before setContentView() mehtod

Note: There is no application level protection. You have to add this code in all the activities that you want to protect.

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                WindowManager.LayoutParams.FLAG_SECURE);
        setContentView(R.layout.activity_main);
    }
}
Riyaz Parasara
  • 154
  • 8
  • 20