0

I want make a screen shot on my device with clicking the button

I use the following code:

View view = getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();

But I found that the picture I captured does not have a status bar. I just want the entire screen of the device. Do you know how can I fix that?

Orlymee
  • 2,349
  • 1
  • 22
  • 24

1 Answers1

0

From above code its not possible, because status bar is not a part of your activity view.

Actually, When you capture image using above code, it just converts the currently drawing view of your application's activity screen, not complete device screen and statusbar appears on top of your screen is a android device's view you don't have a access of this entire view (with status bar).

If you want to get complete screen image then, you have to root access of your device and by reading android device's frame-buffer and then convert it to image file. Then you can get the complete device's screen image (With statusbar or any other view).

user370305
  • 108,599
  • 23
  • 164
  • 151