Setting FLAG_SECURE does not work when added to onPause in Android

504 views Asked by At

I want to Add secure Flag when app goes into background and i want to clear secure flag when app comes to foreground

but onPause is running bit late and content is not hiding in Task Switcher

@Override
protected void onPause() {
  super.onPause();
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}

@Override
protected void onResume() {
  super.onResume();
  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
0

There are 0 answers