Search code examples
android

Need to hide content of program from Android "Overview Screen"


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.

Things I've tried:

  • 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.)

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


Solution

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

    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.