So, I have a Camera Preview (backed by a surface view) and has regular Android UI views laid as overlay over the preview. How do I take a simple screenshot of the displayed screen view.
I tried with MediaProjection
and could not make it work (I am still figuring out why is it not working). But I would like to use MediaProjection
only as the last option as it involves launching a new activity. I also read about this new API PixelCopy
but not sure if it will work for a composited view (of surafceview and regular views) but still to figure out if that API will work for me.
Please note that I am attempting to take a screenshot of the screen when it is basically showing 2 windows and their respective surfaces compositing to provide the final display. Anybody having a sample code for this scenario or some pointer would be appreciated.