Is it possible to capture only a part of the scree

2019-04-14 22:08发布

问题:

Android allows to capture a full screen into an image or a video, using the MediaProjection class (shown here for example for images).

I was wondering how far can we go with this :

  1. Is it possible to capture only a specific area of the screen?

  2. Is it possible to capture an image of a specific view of another app ?

  3. Is it possible to get the bitmap of an ImageView of another app (the one that's saved using setImageBitmap, for example) ?

回答1:

No, no and no. This API basically gives you access to a copy of the hardware screen buffer. You can manipulate its contents, but you get only a full screen bitmap. There's no way to get any specific view or a class from another app. I imagine that that would be a major security flaw it it was possible.