How to prevent screen capturing in Android

Published by Igor Khrupin on

Prevent screen capturing is way for saving your content.

Android SDK have special flag for it.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE

Just declare it in your Activity like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    .....
}

And user will see next message when try make screenshot:

2016-11-25-11-02-43


0 Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.