taking screenshot of device screen [duplicate]

2019-09-24 08:38发布

问题:

This question is an exact duplicate of:

  • Taking screenshot of screen(programmatically) 2 answers

I know this question has been asked many times.I am aware of two ways to do it.(1)Using screenshot library(But I am getting black screen all the time).(2)getting data from frame buffer with rooting||\dev\graphics\fb0||(But it is always 0 byte and I do not know exact location where current screenshot of device is stored).My preferred requirement is getting better frame rate.Any help will be very helpful as I have spent a lot of time in this.

回答1:

You can get the drawing cache of your view using the following code:

    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap b1 = view.getDrawingCache();


回答2:

You can use this:

$ adb shell screencap -p /mnt/sdcard/sc.png
$ adb pull /mnt/sdcard/sc.png