简体   繁体   English

防止 Android 应用程序中的屏幕捕获

[英]prevent screen capture in Android apps

I was wondering if there is a way to detect through some "onXXXXX" call-back method or received broadcast if some other process is about to take a screen-shot of my app's display.我想知道是否有一种方法可以通过某些“onXXXXX”回调方法或接收到的广播来检测是否有其他进程即将截取我的应用程序显示的屏幕截图。 For example if the SDK tools or some other screen capturing app performs a "Screen Capture", I would like to be notified and then decide if I should allow or disallow the screen capture.例如,如果 SDK 工具或其他一些屏幕捕获应用程序执行“屏幕捕获”,我希望收到通知,然后决定我应该允许还是禁止屏幕捕获。

If this is not possible is there a way to lock the display so no other process can screen capture my display?如果这是不可能的,有没有办法锁定显示,所以没有其他进程可以截屏我的显示?

This worked for me on a Samsung Tab 2 7"这在三星 Tab 2 7" 上对我有用

Using the following approach , to simply add the FLAG_SECURE to the Window Flags使用以下方法,只需将FLAG_SECURE添加到 Window 标志

public class FlagSecureTestActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(LayoutParams.FLAG_SECURE,
                         LayoutParams.FLAG_SECURE);

    setContentView(R.layout.main);
  }
}

with the caveat that you may need to change需要注意的是您可能需要更改

LayoutParams

to

WindowManager.LayoutParams

There is no supported method to take a screenshot of another app on Android. 不支持在 Android 上截取另一个应用程序的方法。 The only ways involve either rooting or using the SDK, which both offer little to no chance of you either blocking or receiving notification of it.唯一的方法涉及生根或使用 SDK,这两种方法都几乎没有机会阻止或接收它的通知。 If another app takes your screenshot, it is by default using non-supported methods and can probably do as it pleases.如果另一个应用程序截取了您的屏幕截图,则默认情况下它使用不受支持的方法,并且可能随心所欲。

I'd like to clarify that I am not implying you shouldn't use any methods available to secure your app.我想澄清一下,我并不是暗示您不应该使用任何可用的方法来保护您的应用程序。 I'm just letting you know that it is probably impossible to do so without using non-supported methods, and that even if you do use them you may not be 100% secure against screenshots.我只是让您知道,如果不使用不受支持的方法,可能无法做到这一点,而且即使您确实使用它们,您也可能无法 100% 安全地防止屏幕截图。

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

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