Android 14 introduces a brand new privacy-preserving screenshot detection API that permits apps to detect when a consumer takes a screenshot. The API permits an utility to register callbacks on the exercise degree. When taking a screenshot, a visible message is displayed and recalled. You will need to notice that the callback doesn’t present a picture of the screenshot and presently solely helps screenshots taken with a particular {hardware} button press mixture. Screenshot taken with adb
examine command or gadget with DeviceCapture
unsupported.
To get began, add the next permission to the manifest
In exercise, register and unsubscribe callback and execute ScreenCaptureCallback
show
Alternatively, you’ll be able to create an nameless object of the interface and use it as follows
If you’re testing this on an emulator, use this adb
command to activate the {hardware} mixture to take a screenshot.
adb shell enter keyevent 120
Learn extra about this API at Android developer