Screenshot of current screen

I am working on an Android application that shares a screen with another Android device. This app will run in the background as a service.

I want to capture the screen (current screen), save it as a JPEG, and send it continuously via UDP to another Android device.

But my problem is how to capture the current screen by capturing the framebuffer.

Please, help.

+6
source share
2 answers

You can take a screenshot of the layout by enabling

setDrawingCacheEnabled(true); 

representation.

Mark the link

+3
source

Access the Android framebuffer (and other Linux systems) by opening the device / dev / graphics / fb 0. This requires root access, and even when using root, it will not work properly on all devices. Most devices use a pair of framebuffers and switch between them. The big problem is that even with a root phone, the Dalvik machine user ID does not have access to the frame buffer device (fb0). This means that you can never open and read from fb0 directly from Java code. You will need to run your own linux application with root privileges and it will be able to access fb0 (after the user gives permission). I managed to make this work, and it is rather complicated, and also frowned on Google. I can still potentially turn this into a commercial application, but limitations and incompatibilities make the probability pretty low.

+7
source

Source: https://habr.com/ru/post/904481/


All Articles