0

I am trying to show a different view when the app is browsed in task switcher. This is achieved via a fragment that is attached to the activity.

class ProtectorFragment: Fragment(){
   override fun onCreateView(inflater: LayoutInflater, ...): View? {
    return inflater.inflate(R.layout.fragment_protector...)
   }

  override fun onResume() {
      super.onResume()
      background.visibility = View.GONE
  }

  override fun onPause() {
      super.onPause()
      background.visibility = View.VISIBLE
  }
}

However, it doesn't work as expected in Android 6,7 & 10 devices. Protector view appears for a second and disappears. No View.GONE / INVISIBLE calls are made.

View that is protected

Protector View on top as soon as app hit background

Protector View is gone after a second

But, what is more confusing is, Layout inspector shows the protector view. But, device shows a view that is underneath the Protector view. And, the bottom navigation view also always on top whatever the elevation I set.

What Layout inspector shows all the time the app is in bg

Any clues?

Github link

Bavan
  • 1,021
  • 1
  • 10
  • 24
  • 1
    The preview in the task switcher is not live. The system is showing a screenshot of the UI when the app was paused. If you want to avoid this screenshot to be shown you can use the [FLAG_SECURE](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE). Refer to [this question](https://stackoverflow.com/questions/9822076/how-do-i-prevent-android-taking-a-screenshot-when-my-app-goes-to-the-background). – gpunto Jul 05 '19 at 07:29
  • Thank you. So, there is no way i could show my custom screenshot? When i searched, it seems they have completely removed the ability to add custom screenshots, yet I see lot of banking applications secure their apps in bg with custom screenshots. Anyway, thanks again for your input. – Bavan Jul 05 '19 at 20:20

0 Answers0