4

My question is similar to this question from a few years ago but that question was never answered and I'd like to find out if anything has changed since it was asked.

I'd like to programmatically capture a screenshot of a webview which has flash elements. When I try and use the methods that are most widely described online (using view.draw and view.getDrawingCache) the flash elements do not get captured. I believe this has to do with software vs hardware rendering of the elements. Please let me know if I'm off base on this.

I don't actually need to do this in the final app, only during development, so I'd be open to some adb hackery but the app needs to be able to trigger the screenshot.

I would really appreciate any ideas.

Thanks

Community
  • 1
  • 1
Bi Rico
  • 25,283
  • 3
  • 52
  • 75

3 Answers3

2

Do you have root permissions? If yes - you could read the graphics buffer directly, accessing it via /dev/graphics/fb0.

Here is a discussion how to do it via adb.

Here is a post how to do it programmatically (you'll need to wrap the code with JNI layer)

Community
  • 1
  • 1
user2551017
  • 153
  • 10
1

I have not tried this approach, but theoretically speaking cant you use reflection to get a handle of the

com.android.systemui.screenshot.GlobalScreenshot

void takeScreenshot(Runnable finisher, boolean statusBarVisible, boolean navBarVisible)

to view this code http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/com/android/systemui/screenshot/GlobalScreenshot.java#GlobalScreenshot.takeScreenshot%28java.lang.Runnable%2Cboolean%2Cboolean%29

ichthyocentaurs
  • 2,173
  • 21
  • 35
0

following lines should wok for you :)

browser.setDrawingCacheEnabled(true);
   browser.buildDrawingCache();
   Bitmap bitmap = browser.getDrawingCache();
  • Yep that's what I have. The static parts of the web page get captured, the flash part is just a black square. – Bi Rico Apr 07 '15 at 14:41