2

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);
}
Manikanta
  • 325
  • 6
  • 20
  • what is your requirement exactly? why do you need to clear flags when app is in foreground? can you please explain your use case? – inkredusk Apr 10 '23 at 13:20
  • @inkredusk I am unable to take screenshot in foreground state, that's why i want to clear secure_flag when app comes to foreground – Manikanta Apr 10 '23 at 13:47
  • So the user is allowed to make screen shots but Android is disallowed? If you want to allow screen shots may be the better idea is to integrate a screen shot function into your app. – Robert Apr 10 '23 at 15:08
  • @Robert is there any way to hide content with custom view when app is in background like Phone pay App doing right now? – Manikanta Apr 11 '23 at 03:05

0 Answers0