Based in this answer I think that exists a solution at least to system apps (or probably also in rooted devices?). Happens that i not understood the code example linked on answer comments. Someone could explain a step by step to achieve this please (with a code example if possible)? Thanks in advance.
-
this is not possible. you can remove your over but can't manage third-party application overlay. – Imtiyaz Khalani Jul 27 '21 at 12:44
-
@ImtiyazKhalani, thank you by comment. I'm interested to know how make this exactly to exclude my own overlay. Third-party application overlay not is important to me. – Jul 27 '21 at 14:52
-
you have to remove your overlay during capturing screenshots? – Imtiyaz Khalani Jul 28 '21 at 07:49
-
@ImtiyazKhalani, Yes. – Jul 28 '21 at 10:46
-
... get the visible screen's drawable (root view), delete views you dont need, dump it into a bitmap and voila? – Shark Aug 10 '21 at 14:17
3 Answers
Because of androids way of handling screenshots, excluding the overlay is not possible. But you could, as stated in your link, make the screenshot without your overlay.
This would result in having unrendered holes in your screenshot, whrere there would be only a black background.
If you want that, you could easyly just make your overlay black of the second you shoot the screenshot, or even disable the visibility, to get a clean screenshot. To give you a more detailed answer, we would need a more prescise question with examples and ideas how you wrote your code.
EDIT:
The problem is, that you could theoretically dig into androids source code and change the screenshot behaviour. But with that you would create a new Android version on your own. As @Hassan Uddin stated. Running that on your phone would require you to dig deep into androids source code and possibly not find any answer there.

- 328
- 4
- 15
-
This long comment could be include on answer, except this part ( **If you want to get the excact answer from that post, why not ask under that post if you can get any help from @reker? He seems to have gooten to the point you need to know?** ) above and then deleted. – Aug 10 '21 at 02:16
It is not possible because it's like a security feature. If you are willing to spy on someone's screen, then you are too late it's 2021... the OS will not let you do so... you have to MOD the OS instead

- 417
- 5
- 10
-
-
1@Coringa Already told you bro.... it's possible and everything is possible if you violate the system software somehow (e.g. using root permission.) >> By the way, he talked about to see OS's [source code](https://android.googlesource.com/platform/frameworks/base/+/b267554/services/java/com/android/server/display/OverlayDisplayAdapter.java) here you can only understand how it generally works.... Android is an open source operating system. Your Manufacturer might be Modified it for your phone or not, hope you got the ans this time ------- – Hassan Uddin Jul 31 '21 at 04:52
You can not exclude overlay from screen capture. you can hide or make it transparent in case of your overlay. you can not handle third part overlay.

- 2,037
- 18
- 32
-
[This is possible](https://stackoverflow.com/a/41031064/13342561). But unfortunately i and you not know do. **-1** – Jul 29 '21 at 19:46