在 Android 4.0+ 上检测屏幕截图尝试 [英] Detect screenshot attempts on Android 4.0+

查看:42
本文介绍了在 Android 4.0+ 上检测屏幕截图尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Android 应用程序,它高度重视保护用户数据,以至于在本地设备的持久内存中不存储任何内容.

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.

为了进一步保护用户数据,我们希望在有人试图截取活动应用程序的屏幕截图时对我们的服务器进行网络服务调用.

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.

我目前看到的解决方案包括这个片段 旨在防止截取屏幕截图并在 Toast 中向用户抛出屏幕截图失败消息.我正在考虑的另一种方法是监听某些设备用来截屏的音量调低和电源按钮的组合(尽管三星 S4 等设备偏离了这种方法).我最后的手段是使用 FileObserver 在屏幕截图库的位置进行更改,而应用程序正在运行,但这似乎也是一个次优解决方案,并引入了我不想拥有的权限请求.我也无法确定图像的文件目的地.

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. 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). 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. I also can't be sure of the file destination for the images.

我相信 Snapchat 应用程序能够在远程用户尝试截取屏幕截图时提醒参与者.除了扎根设备之外,您对如何实现此功能有任何建议吗?也欢迎使用非官方方法.

I believe the Snapchat app is able to alert participants when a remote user attempts to take a screenshot. 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 可能是避免在窗口中出现屏幕截图的最佳方式,但正如一些评论者所说,它有一些解决方法.

FLAG_SECURE is probably the best way to avoid screenshots in a window, but as some commenters say here it has some workarounds.

也许 这个答案 解决了他们如何在 Snapchat 中检测屏幕截图的问题拍摄.

Maybe this answer solves the question about how do they do it in Snapchat to detect when a screenshot has been taken.

这篇关于在 Android 4.0+ 上检测屏幕截图尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆