2

Android 5.0 introduced new APIs for screen capture. It also provides an (updated) sample project on how to use it.

I have two questions:

  1. I have run the sample project, it looks like the function which actually render the screen content to SurfaceView is createVirtualDisplay() which returns an instance of VirtualDisplay. How could I generate image file from this VirtualDisplay instance?

  2. Are these screen capture APIs can only be used to capture my app’s screen? Could it also be used to capture any screen even my app is not running in the foreground? According to the sample project, it always needs to ask for a user’s permission before capturing screen, and that permission dialog is popped up by calling startActivityForResult(...). Looks like it can only capture my app’s screenshot. Anyone knows more about this?

Fabiano Soriani
  • 8,182
  • 9
  • 43
  • 59
Leem.fin
  • 40,781
  • 83
  • 202
  • 354

0 Answers0