如何影响到应用程序将在后台的Andr​​oid创建快照 [英] How to affect the snapshot Android takes from application when going to background

查看:123
本文介绍了如何影响到应用程序将在后台的Andr​​oid创建快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于进入后台时服用的应用程序屏幕快照的Andr​​oid系统。我的应用程序,我想在这一点上隐藏一些安全的内容,因此,如果用户输入的背景,并打开最近的应用程序,我总能表现出我的应用程序,而不是之前的最后一个屏幕上看到相同的内容(例如闪屏)输入到背景

My question is about the Android system taking snapshot of application screen when entering background. I have some secure content in application which I would like to hide in that point, so if user enters background and opens recent apps, I could show always the same content (for example splash screen) for my application instead of the last screen visible before entered to background.

这是可能的吗?

感谢。

请不要发布有关FLAG_SECURE答案,我不希望屏幕是黑色,也发现了一个错误,从它:的 HTTP://$c$c.google.com/p/android/issues/detail ID = 64086

Please do not post answers about FLAG_SECURE, I do not want the screen to be black and also found a bug from it: http://code.google.com/p/android/issues/detail?id=64086

推荐答案

使用<一个href="http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE"相对=nofollow> FLAG_SECURE 。

用法:

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

这是一个截图,将prevent所采取的活动。而且将显示空白屏幕,在最近的应用程序列表中的应用程序。

That will prevent from a screenshot being taken of that activity. And will show a blank screen for that app in the recent apps list.

编辑:

除了 FLAG_SECURE 也似乎没有任何方法,以prevent被采取的截图。不过,我建议这种不洁的解决办法,而不是。我还没有试过,只是一个想法:

Other than FLAG_SECURE there doesn't seem any method to prevent a screenshot from being taken. However, I'd suggest this unclean workaround instead. I've not tried this, just an idea:

  1. 重写活动的的onPause() onBack pressed()的方法。所以,当家庭或后退按钮是pressed,这些被称为。

  1. Override the onPause() and onBackPressed() methods of the Activity. So when the home or back button are pressed, these are called.

那么,这些里面,使用的setContentView()来展现另一种虚拟视图或闪屏为此事。所以,这飞溅观点成为最后一个视图中显示。

Then , inside these, use setContentView() to show another dummy view or a splash screen for that matter. So that this splash view becomes the last shown View.

之后 2点,调用 super.onPause() super.onBack pressed这个启动画面(),以便截图取。 2点之前,不要给他们打电话。

After point 2, call super.onPause() or super.onBackPressed() , so that the screenshot is taken, of this splash screen. Don't call them before point 2.

这篇关于如何影响到应用程序将在后台的Andr​​oid创建快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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