需要从Android“概述屏幕"隐藏程序内容 [英] Need to hide content of program from Android "Overview Screen"

查看:92
本文介绍了需要从Android“概述屏幕"隐藏程序内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个注重安全性的雇主开发Android应用程序.他担心出现在概述屏幕(也称为最近任务列表")泄漏敏感信息,并希望我在系统拍摄该图片之前先放置该程序的启动屏幕.不幸的是,我还没有找到任何方法.

I'm working on an Android app for a security-conscious employer. He's concerned about the screen snapshot that appears on the Overview Screen (a.k.a. the recent-tasks list) leaking sensitive information, and wants me to put up the program's splash screen before the system takes that picture. Unfortunately I haven't found any way to do so.

我尝试过的事情:

  • onPause功能中为初始屏幕的视图添加视图. (即使使用bringToFrontsetVisibility(View.VISIBLE)也无效.)
  • onCreate中为启动屏幕的视图充气,并在onPause中使用bringToFront. (再次,没有效果.)
  • onPause中呼叫setVisible(false). (似乎几乎可以正常工作,因为从程序中退出时,屏幕会闪烁黑色一瞬间,但显然在快照之前系统又可以看到它了.)
  • onPause中的视图的最顶层项目上调用setVisibility(View.INVISIBLE). (似乎可以使用,但是快照显然是在生效之前拍摄的.)
  • Inflate the splash screen's View in the onPause function. (No effect, even with bringToFront and setVisibility(View.VISIBLE).)
  • Inflate the splash screen's View in onCreate and use bringToFront in onPause. (Again, no effect.)
  • Calling setVisible(false) in onPause. (Seemed to almost work, in that the screen blinks to black for an instant when switching away from the program, but it's apparently made visible by the system again before the snapshot.)
  • Calling setVisibility(View.INVISIBLE) on the topmost item of the View in onPause. (Seems like it will work, but the snapshot is apparently taken before it takes effect.)

我是一名中等水平的Android开发人员,但我不禁感到缺少一个简单的解决方案.

I'm a moderately accomplished Android developer, but I can't help but feel that there's a simple solution that I'm missing.

推荐答案

我个人会使用FLAG_SECURE 进行操作,并在任何地方简单地阻止这些内容的显示:

Personally, I would go with FLAG_SECURE, and simply block display of this stuff everywhere:

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);
  }
}

但是,IIRC,您可以覆盖onCreateThumbnail()以提供您自己的映像以用于近期任务"列表.请注意,这可能在Android 5.0上有所改变,因为他们已经检查了最近任务"列表,因此请确保在5.0设备或仿真器上测试您的代码.

However, IIRC, you can override onCreateThumbnail() to supply your own image to use for the recent-tasks list. Note that this might have changed with Android 5.0, as they have overhauled that recent-tasks list, so be sure to test your code on a 5.0 device or emulator.

这篇关于需要从Android“概述屏幕"隐藏程序内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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