A new requirement for the company’s project is to monitor the system screenshots of mobile phones and report buried data. I took the opportunity to make a plug-in that can listen to android and ios phone screenshots. I am an Android developer, and the Android part of this plug-in was completed by myself, while the ios part was completed by ios colleagues of the company. Plugin address :github.com/fish89757/s…

Note: The Android implementation of the screenshot listening method is to add a listener to the gallery, listen for the change of the screenshot folder, so here is the need for external storage read permission, the plugin also provides a callback when this permission is not available, you can handle the situation in this callback.

Using methods (which can be called using cascade operators or in steps) :

/ / you can use the cascade operator call ScreenShotListenPlugin. Instance.. startListen() .. AddScreenShotListener ((path) {debugPrint (" screenshots > > > > > > > > > > $path "); }).. AddNoPermissionListener (() {debugPrint (" no photo album permissions > > > > > > > > > > "); Permission.storage.request(); });Copy the code

Call it step by step

1. Enable listening

/ / open the monitor ScreenShotListenPlugin. Instance. StartListen ();Copy the code

2. Add the screenshot event callback. Path is the screenshot path (currently only Android has this path).

ScreenShotListenPlugin.instance.addScreenShotListener((path){});
Copy the code

3.Android can add a permission handling event callback, which can handle the case that there is no read storage permission.

ScreenShotListenPlugin. Instance. AddNoPermissionListener (() {/ / can be in here to apply for permission to});Copy the code

4. End listening

ScreenShotListenPlugin. Instance. StopListen ();Copy the code

At present, only Android can get the picture path parameter in the callback, ios does not know how to get this path for the moment, I will update it when I find a way.