Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide views in android when android app is backgrounded (not to stop android to take snapshot when backgrounded) [duplicate]

Tags:

android

I want to hide my views when my app is backgrounded. For e.g. I want to hide this "Live Debug Mode" textview when my app is backgrounded.

Consider this backgrounded app for e.g.

like image 203
Omkar Amberkar Avatar asked Jul 15 '16 20:07

Omkar Amberkar


1 Answers

Add the following code to your onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE);
    setContentView(R.layout.activity_main2);
    //...rest of your code
}
like image 121
Bill Avatar answered Oct 20 '22 23:10

Bill