Detailed Android screenshot event monitoring

1. Preface

The Android system does not have an interface to monitor screen capture events directly, nor does it have a broadcast. It can only provide food and clothing by itself. Generally, there are three methods.

Due to the diversity of manufacturers' customized Android systems, different shortcut keys and third-party applications, monitoring screenshot shortcut keys is basically unreliable and can be ignored directly.

The test phone used in this article is one plus 2 (one plus 2).

2. FileObserver

Add permissions:

Code example:

Printed log:

One plus two

Samsung S4

You can listen to an event by specifying the mask in the constructor.

Several precautions:

Based on the third and fourth points, this method can not be applied to all models.

Note: if you write your demo and don't receive events, check the permissions and the listening directory

3. ContentObserver

Contentobserver is used to monitor all resource changes of the specified URI. We can use it to monitor the changes of image resources and then filter them.

add permission

Code example:

journal:

matters needing attention:

4. Summary

At present, this is a summary of screenshot monitoring methods found on the Internet. If you have any better monitoring methods, please share them.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>