Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

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.

like image 829
Head Geek Avatar asked Dec 04 '14 01:12

Head Geek


1 Answers

Based on @D.Maul 's answer but the Java version, instead of adding a view, I have tried this. It works fairly but sometimes the recent snapshot shows the app content not sure what to do about it.

private Dialog dialog = null;

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  dialog = new Dialog(this, android.R.style.Theme_Light);
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  dialog.setContentView(R.layout.customlaunch);
}

@Override
protected void onPause() {
    dialog.show();
    super.onPause();
}
    
@Override
protected void onResume() {
     dialog.hide();
     super.onResume();
}
like image 188
Satheesh Avatar answered Sep 25 '22 07:09

Satheesh