简体   繁体   English

检测Android 4.0+上的屏幕截图尝试

[英]Detect screenshot attempts on Android 4.0+

I am developing an Android application that places a high priority on protecting the user's data, to the point of storing nothing in persistent memory on the local device. 我正在开发一个Android应用程序,它高度重视保护用户的数据,以便在本地设备的永久内存中不存储任何东西。

To further protect user data, we want to make a web-service call to our server whenever someone attempts to take a screenshot of the active application. 为了进一步保护用户数据,我们希望每当有人试图截取活动应用程序的屏幕截图时,都会向我们的服务器发出Web服务调用。

Solutions that I have seen so far include this snippet intended to prevent the screenshot from being taken and throwing a screenshot failure message in a Toast at the user. 到目前为止,我看到的解决方案包括这个片段,旨在防止截屏被截取并在用户的Toast中抛出屏幕截图失败消息。 Another approach I was considering was listening for the combination of Volume Down and Power button that some devices use to take screenshots (though devices such as the Samsung S4 deviate from this method). 我正在考虑的另一种方法是收听一些设备用来截取屏幕截图和电源按钮的组合(尽管三星S4等设备偏离此方法)。 My last resort was going to use a FileObserver in the location of the screenshot Gallery for changes while the app is running, but that also seems like a sub-optimal solution and introduces a Permission request that I'd rather not have. 我最后的办法是在应用程序运行时在屏幕截图库中使用FileObserver进行更改,但这似乎也是次优解决方案并引入了我不想拥有的权限请求。 I also can't be sure of the file destination for the images. 我也无法确定图像的文件目的地。

I believe the Snapchat app is able to alert participants when a remote user attempts to take a screenshot. 我相信Snapchat应用程序能够在远程用户尝试截取屏幕截图时提醒参与者。 Do you have any suggestions on how this feature might be implemented, short of rooting the device? 对于如何实现此功能,您有什么建议吗? Non-official methods are welcome as well. 也欢迎非官方方法。

FLAG_SECURE is probably the best way to avoid screenshots in a window, but as some commenters say here it has some workarounds. FLAG_SECURE可能是在窗口中避免屏幕截图的最佳方法,但正如一些评论者在这里所说的,它有一些解决方法。

Maybe this answer solves the question about how do they do it in Snapchat to detect when a screenshot has been taken. 也许这个答案解决了他们如何在Snapchat中做这件事以检测截图何时拍摄的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM