Which means what? What exactly are you doing, and what exactly is the result? Tells us which lines of code are being executed, which ones are not being executed and how that differs from what you expected.
The part with the ByteArrayOutputStream and ByteArrayInputStream looks unnecessarily complicated. Why doesn't bmp.compress write directly into the FileOutputStream?
Also note that if InputStream.read returns 0, that does NOT mean that the end of the input has been reached. That's what -1 means.
ok you can simplify, but the problem lies in the fact that I try to capture the screen in a SurfaceView and I read on the internet that is a little more complicated than usual, and despite my best efforts I can not create the screenshot