How to disable Screenshot in Android

Sometimes it can happen, that the app has to prevent android from taking a screenshot of the app. This can make sense if the app is being pushed into the background and/or for security reasons. So use FLAG_SECURE:

This line secures against manual screenshots and automatic screenshots from the ICS recent-tasks history. You still see the application name and icon, but the screenshot is black.

Note: On some android devices FLAG_SECURE can be problematic: Sometimes FLAG_SECURE causes animation problems in screen rotation animation. See code.google.com/p/android/issues/detail?id=58632 – this has been fixed on Android 4.4.