0

In android For security reasons I want to hide some of the texts or views , when app is moved to recent apps in task manager. I tried to handle this by below ways but before going to the lifecyle it takes the screen shot for recent app view.
1. Inside onPause()
2. Inside onWindowFocusChanged()
3. Inside onUserLeaveHint()

All the above called after screen shot taken for recent apps 1. Its never been called onCreateThumbnail() (I don't want to hide complete screen, only the textviews has to be hidden) Please anyone have a solution for this issue ?

In Android 8.0 its doing after on pause but earlier versions how to handle.

ADM
  • 20,406
  • 11
  • 52
  • 83

1 Answers1

4

The way I do it is by calling

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);

after setContentView(R.layout.yours) in onCreate().

Montwell
  • 505
  • 3
  • 12
  • Thanks!!! this really helped, I was thinking of hiding the content in onPause and showing in onResume, But adding a flag seems a better solution. – Chetan Gaikwad Jan 15 '19 at 08:06