WindowCapture


public final class WindowCapture


Summary

Public methods

static final @NonNull ListenableFuture<@NonNull Bitmap>

Asynchronously captures an image of the underlying window into a Bitmap.

Public methods

captureRegionToBitmap

@ExperimentalTestApi
public static final @NonNull ListenableFuture<@NonNull BitmapcaptureRegionToBitmap(@NonNull Window receiver, Rect boundsInWindow)

Asynchronously captures an image of the underlying window into a Bitmap.

For devices below Build.VERSION_CODES#O the image is obtained using View#draw on the windows decorView. Otherwise, PixelCopy is used.

This method will also enable HardwareRendererCompat#setDrawingEnabled(boolean) if required.

This API is primarily intended for use in lower layer libraries or frameworks. For test authors, its recommended to use espresso or compose's captureToImage.

This API is currently experimental and subject to change or removal.