Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taking Screenshot of Current screen

I am working on an application on Android which will share the screen to another android device.This app will run in background as service.

I want to capture the screen (current screen),save it as JPEG and continously send it over UDP to other Android device.

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

Please help.

like image 769
user1095154 Avatar asked Dec 26 '11 09:12

user1095154


1 Answers

The Android framebuffer (and on other linux systems) is accessed by opening the /dev/graphics/fb0 device. This requires root access and even with root access it won't work properly on all devices. Most devices use a pair of framebuffers and toggle between them. The bigger problem is that even with a rooted phone, the Dalvik machine's user ID does not have the privilege to access the frame buffer (fb0) device. This means that you will never be able to open and read from the fb0 device directly from Java code. You will need to run a native linux application as root and it will be able to access fb0 (after the user gives permission). I succeeded in making this work and it is quite challenging and also frowned upon by Google. I still may potentially turn this into a commercial application, but the limitations and incompatibilities put the probability quite low.

like image 168
BitBank Avatar answered Nov 25 '22 03:11

BitBank