bhaskar
bhaskar

Reputation: 50

Background application UI has to become blurred when the user sends the foreground app to background by pressing the device home button

User sends current running application in android device to background and when try to see all background application in device user should not able to see content of the background application. instead of that user has to see either blurred or blank screen and on tap it when application comes on foreground user can able to see actual content.

Upvotes: 2

Views: 2288

Answers (2)

  • activity.setRecentsScreenshotEnabled(false) can solve your problem. But it only work with android 13 and above.

  • Or you can use window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) for all android device.

  • Note: Both of 2 methods above work on some device, some device will not work when click home button or turn on gesture navigation. So I write a small project to handle that you can investigate more here https://github.com/hungnb94/blur-background. I hope it will help you to solve your problem

Upvotes: 0

Prexx
Prexx

Reputation: 2979

Set this in onCreate method between super.onCreate(savedInstanceState) and setContentView:

 // White image on recent apps overview and disable screenshot functionality
 window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)

Upvotes: 3

Related Questions