Replace image from recent app menu

China☆狼群 提交于 2019-12-05 02:42:27

问题


In my app are activities which are displaying user sensitive data (inbox, passwords, bank account balance etc.). These sections are of course password protected and user is automatically logged off after some amount of time (this is checked in onRestart()). Problem is when this app is running on Android 3.0+ (which has recent app menu with images of recent apps) that these sensitive data are readable in this menu. Is there way to change that image to application logo or something else?
I already tried starting those sections in new task with EXCLUDE_FROM_RECENTS flag which helped but is interupting the user experience.
Other option is in onPause() method try to start some sort of "logo activity" which will be stopped in onRestart() and will be shown in recent app menu.
Any other/better suggestions? Thanks!


回答1:


Is there way to change that image to application logo or something else?

Adding FLAG_SECURE to the window handles this, IIRC:

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

This also blocks screenshots on ICS devices with screenshot support.



来源:https://stackoverflow.com/questions/10533186/replace-image-from-recent-app-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!