Reputation: 842
So I have a service that runs an overlay view from my app (think like the facebook messenger icon). When you click on this it opens up another view that has some information on it. Is there a way to block that view only from showing when the user takes a screenshot on their device? I do not mean using getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
to stop screenshots all together, but just make that view invisible when a screenshot is taken?
Upvotes: 2
Views: 1004
Reputation: 10190
If i understand the question correctly, you want to protect part of the content from screenshots, but not the whole window. As @CommonsWare suggests, it's not possible. But, there MIGHT be a (silly) solution, if you are desperate.
This solution may seem a bit impractical, and won't be applicable to your use case (or any use case) .. but here it is anyway
Maybe, you could show two windows (and hence, activities) - one with the sensitive content, one with the not-sensitive content (and use FLAG_SECURE
on the sensitive window/activity)
How to display two activities at once?
sensitive
activity, also in split-screen mode using FLAG_ACTIVITY_LAUNCH_ADJACENT (this flag only works if the device is ALREADY in multi-window mode, which we might be able to achieve with AccessibilityService technique)Disclaimer: I haven't tried this. Also, If it works, it will work with Android N and above, obviously. Hope it helps (probably wont, sorry :-) )
Upvotes: 1
Reputation: 1006539
No, sorry — your choices are FLAG_SECURE
for the window, or nothing. You are not informed when a screenshot is about to be taken to possibly do anything in response to it.
Upvotes: 1