Android-ScreenshotDetection
Screenshot Detection Library
Download
Since version 1.0.1 will move from JCenter to MavenCentral
Gradle
implementation 'com.akexorcist:screenshot-detection:1.0.1'
Permission in this library
This library has declared the permission to read the external storage. So you need to handle the runtime permission by yourself. If not, app will not crash and screenshot detection still work but no file path.
Usage
Implement the library to your activity or your base activity.
But above example will not work because read the external storage permission has denied. To fix this, you need to add the code for runtime permission request.
Then extends your target activity with that base activity class and declare onScreenCaptured(path: String)
and onScreenCapturedWithDeniedPermission()
when you want to detect the screenshot.